'How to register SNS topic to bounce (or complaint) email notifications with AWS CDK C#?

I have SES 'verified identity' email, that sends emails. Now using CDK I'm creating SNS topic and Lambda to handle bounce and complaint emails sent by that verified email. Topic and lambda are being created well with CDK, but I cannot find a way how to register my topic to bounce or complaint email notifications (manually it's easy, but not clear how to do it with AWS CDK)

var myLambdaFunction =  new Function(...
var topic = new Topic(this, "BounceTopic", new TopicProps{TopicName = "BounceTopic",   Fifo = false });
topic.AddSubscription(new LambdaSubscription(myLambdaFunction, new LambdaSubscriptionProps()));
           
//I've tried to use this code to subscribe topic to Bounce, but creating BounceActionConfig does not even appear in CloudFormation template (maybe I need to use it as a parameter, but where?)
            var bounceActionConfig = new BounceActionConfig {
                Message = "Bounce email",
                Sender = props.EmailSender,//the verified SES identity email address
                SmtpReplyCode = "smtpReplyCode",
                TopicArn = topic.TopicArn
            };

So I need to make my cdk code to find SES email identity and set it's Bounce and/or complaint notifications to my newly created topic. Should I use this BounceActionConfig or there is another way to do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source