diff --git a/packages/aws-cdk-lib/aws-ses/lib/configuration-set.ts b/packages/aws-cdk-lib/aws-ses/lib/configuration-set.ts index 0492cf8cef9f6..d80bcadebf334 100644 --- a/packages/aws-cdk-lib/aws-ses/lib/configuration-set.ts +++ b/packages/aws-cdk-lib/aws-ses/lib/configuration-set.ts @@ -15,6 +15,13 @@ export interface IConfigurationSet extends IResource { * @attribute */ readonly configurationSetName: string; + + /** + * The ARN of the configuration set + * + * @attribute + */ + readonly configurationSetArn: string; } /** @@ -111,15 +118,27 @@ export enum SuppressionReasons { COMPLAINTS_ONLY = 'COMPLAINTS_ONLY', } +abstract class ConfigurationSetBase extends Resource implements IConfigurationSet { + public abstract configurationSetName: string; + + public get configurationSetArn(): string { + return this.stack.formatArn({ + service: 'ses', + resource: 'configuration-set', + resourceName: this.configurationSetName, + }); + } +} + /** * A configuration set */ -export class ConfigurationSet extends Resource implements IConfigurationSet { +export class ConfigurationSet extends ConfigurationSetBase { /** * Use an existing configuration set */ public static fromConfigurationSetName(scope: Construct, id: string, configurationSetName: string): IConfigurationSet { - class Import extends Resource implements IConfigurationSet { + class Import extends ConfigurationSetBase { public readonly configurationSetName = configurationSetName; } return new Import(scope, id); diff --git a/packages/aws-cdk-lib/aws-ses/test/configuration-set.test.ts b/packages/aws-cdk-lib/aws-ses/test/configuration-set.test.ts index 49f77e5c3034b..2deb68311226a 100644 --- a/packages/aws-cdk-lib/aws-ses/test/configuration-set.test.ts +++ b/packages/aws-cdk-lib/aws-ses/test/configuration-set.test.ts @@ -40,3 +40,38 @@ test('configuration set with options', () => { }, }); }); + +test('renders the correct ARN for owned ConfigurationSet', () => { + const configurationSet = new ConfigurationSet(stack, 'ConfigurationSet'); + const arn = stack.resolve(configurationSet.configurationSetArn); + expect(arn).toEqual({ + 'Fn::Join': ['', [ + 'arn:', + { Ref: 'AWS::Partition' }, + ':ses:', + { Ref: 'AWS::Region' }, + ':', + { Ref: 'AWS::AccountId' }, + ':configuration-set/', + { + Ref: 'ConfigurationSet3DD38186', + }, + ]], + }); +}); + +test('renders the correct ARN for unowned ConfigurationSet', () => { + const unownedConfigurationSet = ConfigurationSet.fromConfigurationSetName(stack, 'ConfigurationSet', 'my-imported-configuration-set'); + const arn = stack.resolve(unownedConfigurationSet.configurationSetArn); + expect(arn).toEqual({ + 'Fn::Join': ['', [ + 'arn:', + { Ref: 'AWS::Partition' }, + ':ses:', + { Ref: 'AWS::Region' }, + ':', + { Ref: 'AWS::AccountId' }, + ':configuration-set/my-imported-configuration-set', + ]], + }); +}); \ No newline at end of file