Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert changes to configureAws #266

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import nodemailer from 'nodemailer'
import directTransport from 'nodemailer-direct-transport'
import Mail from 'nodemailer/lib/mailer'
import SMTPPool from 'nodemailer/lib/smtp-pool'
import { promisify } from 'util'

import defaults from './defaults'
import { createLoggerWithLabel } from './logger'
Expand Down Expand Up @@ -371,15 +370,24 @@ const cookieSettings: SessionOptions['cookie'] = {
// Functions
const configureAws = async () => {
if (!isDev) {
// Convert to async function, then call and await
await promisify(aws.config.getCredentials)()
}
// In dev environment, credentials should be set from env vars
if (!aws.config.credentials.accessKeyId) {
throw new Error(`AWS Access Key Id is missing`)
}
if (!aws.config.credentials.secretAccessKey) {
throw new Error(`AWS Secret Access Key is missing`)
const getCredentials = () => {
return new Promise((resolve, reject) => {
aws.config.getCredentials((err) => {
if (err) {
reject(err)
} else {
resolve()
}
})
})
}
await getCredentials()
if (!aws.config.credentials.accessKeyId) {
throw new Error(`AWS Access Key Id is missing`)
}
if (!aws.config.credentials.secretAccessKey) {
throw new Error(`AWS Secret Access Key is missing`)
}
}
}

Expand Down