How to add default configuration set to an existing domain identity in SES using AWS CDK?

0

Hi, I have created a configuration set in SES using CDK. I need to add this configuration set as default configuration set to an existing verified domain identity in SES. Please help me with your valuable suggestions. thanks.

1 Answer
0

Hello,

To add a default configuration set to an existing domain identity in Amazon SES (Simple Email Service) using the AWS CDK (Cloud Development Kit), you can follow these steps:

  1. Install AWS CDK: If you haven't already, you need to install the AWS CDK and set up your project.
  2. Import Required Modules: Import the necessary modules from AWS CDK and AWS SDK.
  3. Retrieve the Identity ARN: Retrieve the ARN (Amazon Resource Name) of the existing domain identity you want to add the default configuration set to.
  4. Create the Configuration Set: Define a new configuration set using the ses.CfnConfigurationSet construct.
  5. Add the Default Configuration Set to the Domain Identity: Use the ses.CfnIdentityConfigurationSet construct to associate the configuration set with the domain identity.

Below is an example code snippet demonstrating these steps:

import * as cdk from '@aws-cdk/core'; import * as ses from '@aws-cdk/aws-ses'; import * as sesv2 from '@aws-cdk/aws-sesv2'; import * as iam from '@aws-cdk/aws-iam';

export class AddDefaultConfigSetToDomainIdentityStack extends cdk.Stack { constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props);

// Replace 'your-domain-identity-arn' with the ARN of your existing domain identity
const domainIdentityArn = 'your-domain-identity-arn';

// Define a new SES Configuration Set
const configSet = new sesv2.CfnConfigurationSet(this, 'MyConfigSet', {
  name: 'MyDefaultConfigSet',
});

// Add permissions for SES to manage the configuration set
const sesPolicy = new iam.PolicyStatement({
  actions: ['ses:UpdateConfigurationSetSendingEnabled'],
  effect: iam.Effect.ALLOW,
  resources: [`arn:aws:ses:${cdk.Stack.of(this).region}:${cdk.Stack.of(this).account}:configuration-set/${configSet.ref}`],
});

// Grant SES permissions to manage the configuration set
configSet.addToResourcePolicy(sesPolicy);

// Associate the Configuration Set with the Domain Identity
new sesv2.CfnIdentityConfigurationSet(this, 'MyIdentityConfigSet', {
  sendingEnabled: true, // Enable sending using this configuration set
  identityType: 'DOMAIN',
  identityName: domainIdentityArn,
  configurationSetName: configSet.ref,
});

} }

const app = new cdk.App(); new AddDefaultConfigSetToDomainIdentityStack(app, 'AddDefaultConfigSetToDomainIdentityStack');

Make sure to replace 'your-domain-identity-arn' with the ARN of your existing domain identity. Also, ensure that your AWS CDK environment is properly configured and has the necessary permissions to interact with SES.

AWS
answered 3 months ago
profile picture
EXPERT
reviewed 24 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions