I want to share a snippet of my CDK TypeScript code that sets up an SES identity and SNS topic:
toolsAccountSES = new EmailIdentity(this, 'ToolsSESidentity', {
identity: Identity.publicHostedZone(hostedZone),
});
// configuring bounce notifications
const bounceTopic = new Topic(this, `ses-bounce-${props.branchName}`, {
topicName: `ses-bounce-${props.branchName}`,
displayName: `SES bounce notifications for ${props.branchName}`,
});
bounceTopic.addSubscription(new EmailSubscription(bounceEmail))
Is there any way to link this topic to the identity for receiving bounce notifications? I have been unable to find a solution in CDK
UPDATE: Implementation of a possible fix
I have developed a construct that handles the creation of the configuration set
export class sesConfig extends Construct {
public configurationSet: ConfigurationSet;
constructor(scope: Construct, id: string) {
super(scope, id);
const bounceTopic = new Topic(this, 'bounce-topic');
bounceTopic.addSubscription(new EmailSubscription(bounceEmail));
this.configurationSet = new ConfigurationSet(this, 'ses-config');
this.configurationSet.addEventDestination('bounce-destination', {
destination: EventDestination.snsTopic(bounceTopic),
events: [EmailSendingEvent.BOUNCE],
});
;
}
}
Then, I provide this construct to the constructor when creating the email identity
new EmailIdentity(scope, 'SubdomainIdentity', {
identity: Identity.publicHostedZone(hostedZone),
configurationSet: new sesConfig(scope, 'ses-config').configurationSet,
});
An email identity is successfully created along with the SNS topic, but upon checking the console, no notification is configured