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

feat: allow custom key names for AWS SES SMTP credentials in Secrets Manager #1478

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/provider/credentials-handler.lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export async function handler(event: OnEventRequest): Promise<OnEventResponse |
// Create access key
const username = event.ResourceProperties.UserName;
const secretId = event.ResourceProperties.SecretId;
const userNameSecretKey = event.ResourceProperties.UserNameSecretKey;
const passwordSecretKey = event.ResourceProperties.PasswordSecretKey;
const region = process.env.AWS_DEFAULT_REGION as string;
const iam = new AWS.IAM();
const secretsManager = new AWS.SecretsManager();
Expand All @@ -36,8 +38,8 @@ export async function handler(event: OnEventRequest): Promise<OnEventResponse |
.putSecretValue({
SecretId: secretId,
SecretString: JSON.stringify({
[Credentials.USERNAME]: accessKeyId,
[Credentials.PASSWORD]: smtpPassword,
[userNameSecretKey || Credentials.USERNAME]: accessKeyId,
[passwordSecretKey || Credentials.PASSWORD]: smtpPassword,
}),
})
.promise();
Expand Down
10 changes: 10 additions & 0 deletions src/ses-smtp-credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export interface SesSmtpCredentialsProps {
* Optional, an SecretsManager secret to write the AWS SES Smtp credentials to.
*/
readonly secret?: secretsmanager.ISecret;
/**
* Optional, the key name to use in the secret to write the username to (defaults to Credentials.USERNAME)
*/
readonly userNameSecretKey?: string;
/**
* Optional, the key name to use in the secret to write the password to (defaults to Credentials.PASSWORD)
*/
readonly passwordSecretKey?: string;
}

/**
Expand Down Expand Up @@ -93,6 +101,8 @@ export class SesSmtpCredentials extends Construct {
properties: {
UserName: user.userName,
SecretId: this.secret.secretArn,
UserNameSecretKey: props.userNameSecretKey,
PasswordSecretKey: props.passwordSecretKey,
},
} as CustomResourceProps);
customResource.node.addDependency(user);
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/integ.default.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading