Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ses-actions): WorkMail rule action #29854

Merged
merged 8 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-ses-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Currently supported are:
* [Lambda](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-lambda.html)
* [S3](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-s3.html)
* [SNS](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-sns.html)
* [WorkMail](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-workmail.html)
* [Stop](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-stop.html)

See the README of `aws-cdk-lib/aws-ses` for more information.
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-ses-actions/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './lambda';
export * from './s3';
export * from './sns';
export * from './stop';
export * from './workmail';
45 changes: 45 additions & 0 deletions packages/aws-cdk-lib/aws-ses-actions/lib/workmail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as ses from '../../aws-ses';
import * as sns from '../../aws-sns';

/**
* Construction properties for a WorkMail action.
*/
export interface WorkMailProps {
/**
* The WorkMail organization ARN.
*
* @example 'arn:aws:workmail:us-east-1:123456789012:organization/m-organizationid'
nmussy marked this conversation as resolved.
Show resolved Hide resolved
*/
readonly organizationArn: string;

/**
* The SNS topic to notify when the WorkMail action is taken.
*
* @default - no topic will be attached to the action
*/
readonly topic?: sns.ITopic;
}

/**
* Integrates an Amazon WorkMail action into a receipt rule set,
* and optionally publishes a notification to Amazon SNS.
*
* Beware that WorkMail should already set up an active `INBOUND_MAIL` rule set
* that includes a WorkMail rule action for this exact purpose.
* This action should be used to customize the behavior of replacement rule set.
*
* @see https://docs.aws.amazon.com/ses/latest/dg/receiving-email-action-workmail.html
*/
export class WorkMail implements ses.IReceiptRuleAction {
constructor(private readonly props: WorkMailProps) {
}

public bind(_rule: ses.IReceiptRule): ses.ReceiptRuleActionConfig {
return {
workmailAction: {
organizationArn: this.props.organizationArn,
topicArn: this.props.topic?.topicArn,
},
};
}
}
23 changes: 23 additions & 0 deletions packages/aws-cdk-lib/aws-ses-actions/test/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,26 @@ test('add stop action', () => {
},
});
});

test('add workmail action', () => {
rule.addAction(new actions.WorkMail({
organizationArn: 'arn:aws:workmail:us-east-1:123456789012:organization/m-organizationid',
topic,
}));

Template.fromStack(stack).hasResourceProperties('AWS::SES::ReceiptRule', {
Rule: {
Actions: [
{
WorkmailAction: {
OrganizationArn: 'arn:aws:workmail:us-east-1:123456789012:organization/m-organizationid',
TopicArn: {
Ref: 'TopicBFC7AF6E',
},
},
},
],
Enabled: true,
},
});
});
Loading