- Newest
- Most votes
- Most comments
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:
- Install AWS CDK: If you haven't already, you need to install the AWS CDK and set up your project.
- Import Required Modules: Import the necessary modules from AWS CDK and AWS SDK.
- Retrieve the Identity ARN: Retrieve the ARN (Amazon Resource Name) of the existing domain identity you want to add the default configuration set to.
- Create the Configuration Set: Define a new configuration set using the ses.CfnConfigurationSet construct.
- 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.
Relevant content
- Accepted Answerasked 2 years ago
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago