Skip to content

Instantly share code, notes, and snippets.

@markilott
Created July 25, 2021 07:36
Show Gist options
  • Save markilott/4d2aa026dc0aa66c630ca20c1eabc878 to your computer and use it in GitHub Desktop.
Save markilott/4d2aa026dc0aa66c630ca20c1eabc878 to your computer and use it in GitHub Desktop.
CDK Custom Resource - SES Domain Identity
// Add and verify Domain using DKIM
const domainIdentity = new AwsCustomResource(this, 'domainIdentity', {
onUpdate: {
service: 'SESV2',
action: 'createEmailIdentity',
parameters: {
EmailIdentity: zoneName,
ConfigurationSetName, // Will set the default Configuration Set for the domain
},
physicalResourceId: {},
},
onDelete: {
service: 'SESV2',
action: 'deleteEmailIdentity',
parameters: {
EmailIdentity: zoneName,
},
},
policy: AwsCustomResourcePolicy.fromStatements([sesPolicy]),
logRetention: 7,
});
// Assuming there are always 3 tokens returned as that is what all the docs indicate
const dkimTokens = [
domainIdentity.getResponseField('DkimAttributes.Tokens.0'),
domainIdentity.getResponseField('DkimAttributes.Tokens.1'),
domainIdentity.getResponseField('DkimAttributes.Tokens.2'),
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment