Skip to content

Commit

Permalink
feat(ses): add configurationSetArn property on configurationSet resource
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericbarthelet committed Apr 23, 2024
1 parent 1bdd3fa commit 7e81307
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/aws-cdk-lib/aws-ses/lib/configuration-set.ts
Expand Up @@ -15,6 +15,13 @@ export interface IConfigurationSet extends IResource {
* @attribute
*/
readonly configurationSetName: string;

/**
* The ARN of the configuration set
*
* @attribute
*/
readonly configurationSetArn: string;
}

/**
Expand Down Expand Up @@ -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);
Expand Down
35 changes: 35 additions & 0 deletions packages/aws-cdk-lib/aws-ses/test/configuration-set.test.ts
Expand Up @@ -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',
]],
});
});

0 comments on commit 7e81307

Please sign in to comment.