Skip to content

Commit 60d7aea

Browse files
feat(ses): https policy for custom tracking domain (#34314)
### Issue # (if applicable) None ### Reason for this change Cloudformation supports for configuring HttpsPolicy for custom tracking domain in `ConfigurationSet` but AWS CDK cannot do this. https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-ses-configurationset-trackingoptions.html#cfn-ses-configurationset-trackingoptions-httpspolicy ### Description of changes - Define `HttpsPolicy` enum - Add `customTrackingHttpsPolicy` to `ConfigurationSetProps` ### Describe any new or updated permissions being added None ### Description of how you validated changes Add both unit and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 2cd737d commit 60d7aea

12 files changed

+373
-2
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.configuration-set-tracking-options.js.snapshot/ConfigurationSetIntegDefaultTestDeployAssert9B6AD46A.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.configuration-set-tracking-options.js.snapshot/ConfigurationSetIntegDefaultTestDeployAssert9B6AD46A.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.configuration-set-tracking-options.js.snapshot/cdk.out

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.configuration-set-tracking-options.js.snapshot/integ.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.configuration-set-tracking-options.js.snapshot/manifest.json

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.configuration-set-tracking-options.js.snapshot/ses-configuration-set-tracking-options-integ.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"Resources": {
3+
"ConfigurationSet3DD38186": {
4+
"Type": "AWS::SES::ConfigurationSet",
5+
"Properties": {
6+
"TrackingOptions": {
7+
"CustomRedirectDomain": "tracking.example.com",
8+
"HttpsPolicy": "REQUIRE"
9+
}
10+
}
11+
}
12+
},
13+
"Parameters": {
14+
"BootstrapVersion": {
15+
"Type": "AWS::SSM::Parameter::Value<String>",
16+
"Default": "/cdk-bootstrap/hnb659fds/version",
17+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
18+
}
19+
},
20+
"Rules": {
21+
"CheckBootstrapVersion": {
22+
"Assertions": [
23+
{
24+
"Assert": {
25+
"Fn::Not": [
26+
{
27+
"Fn::Contains": [
28+
[
29+
"1",
30+
"2",
31+
"3",
32+
"4",
33+
"5"
34+
],
35+
{
36+
"Ref": "BootstrapVersion"
37+
}
38+
]
39+
}
40+
]
41+
},
42+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
43+
}
44+
]
45+
}
46+
}
47+
}

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.configuration-set-tracking-options.js.snapshot/tree.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { App, Stack, StackProps } from 'aws-cdk-lib';
2+
import * as integ from '@aws-cdk/integ-tests-alpha';
3+
import { Construct } from 'constructs';
4+
import * as ses from 'aws-cdk-lib/aws-ses';
5+
6+
/**
7+
* In order to test this you need to have a valid public hosted zone that you can use
8+
* to validate the domain identity.
9+
*
10+
* Step 1: Create a public hosted zone in Route53
11+
* Step 2: Create a email identity in SES and validate it with the hosted zone
12+
* Step 3: Set the hosted zone name as an env var "HOSTED_ZONE_NAME"
13+
* Step 4: Run this test
14+
* Step 5: Correct the hosted zone name in the generated template to `tracking.example.com `
15+
*/
16+
const hostedZoneName = process.env.CDK_INTEG_HOSTED_ZONE_NAME ?? process.env.HOSTED_ZONE_NAME;
17+
if (!hostedZoneName) throw new Error('For this test you must provide your own HostedZoneName as an env var "HOSTED_ZONE_NAME". See framework-integ/README.md for details.');
18+
19+
interface TestStackProps extends StackProps {
20+
hostedZoneName: string;
21+
}
22+
23+
class ConfigurationSetStack extends Stack {
24+
constructor(scope: Construct, id: string, props: TestStackProps) {
25+
super(scope, id, props);
26+
27+
new ses.ConfigurationSet(this, 'ConfigurationSet', {
28+
customTrackingRedirectDomain: `tracking.${props.hostedZoneName}`,
29+
customTrackingHttpsPolicy: ses.HttpsPolicy.REQUIRE,
30+
});
31+
}
32+
}
33+
34+
const app = new App();
35+
36+
new integ.IntegTest(app, 'ConfigurationSetInteg', {
37+
testCases: [new ConfigurationSetStack(app, 'ses-configuration-set-tracking-options-integ', {
38+
hostedZoneName,
39+
})],
40+
stackUpdateWorkflow: false,
41+
});

packages/aws-cdk-lib/aws-ses/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ import { Duration } from 'aws-cdk-lib';
139139
declare const myPool: ses.IDedicatedIpPool;
140140

141141
new ses.ConfigurationSet(this, 'ConfigurationSet', {
142-
customTrackingRedirectDomain: 'track.cdk.dev',
143142
tlsPolicy: ses.ConfigurationSetTlsPolicy.REQUIRE,
144143
dedicatedIpPool: myPool,
145144
// Specify maximum delivery time
@@ -200,6 +199,20 @@ myConfigurationSet.addEventDestination('ToFirehose', {
200199
})
201200
```
202201

202+
#### Tracking options
203+
204+
You can specify to use a custom redirect domain to handle open and click tracking for email sent with this configuration set by using `customTrackingRedirectDomain` and `customTrackingHttpsPolicy`.
205+
Detail can be found in [Custom tracking domain](https://docs.aws.amazon.com/ses/latest/dg/configure-custom-open-click-domains.html).
206+
207+
```ts
208+
new ses.ConfigurationSet(this, 'ConfigurationSet', {
209+
customTrackingRedirectDomain: 'track.cdk.dev',
210+
customTrackingHttpsPolicy: ses.HttpsPolicy.REQUIRE,
211+
});
212+
```
213+
214+
**Note**: The custom tracking redirect domain must be verified in Amazon SES. To create verified identities, you can use the [`EmailIdentity` construct](#email-identity).
215+
203216
### Override account-level suppression list settings
204217

205218
You can customize account-level suppression list separately for different configuration sets by overriding it

0 commit comments

Comments
 (0)