Skip to content

Commit 72ee4a7

Browse files
authored
feat(ses): add fromEmailIdentityArn (#33984)
### Issue # (if applicable) Closes #33981 ### Reason for this change The SES module currently lacks a method to import an `EmailIdentity` by its ARN, which is inconsistent with many other CDK resource libraries. Supporting this would allow users to follow a consistent pattern when managing resources across CDK stacks. ### Description of changes - Added a new static method `EmailIdentity.fromEmailIdentityArn(scope, id, emailIdentityArn)` to enable importing an `EmailIdentity` by ARN. ### Describe any new or updated permissions being added No new IAM permissions are required, as this change does not perform any operations requiring permissions. It only allows referencing an existing SES Email Identity by ARN. ### Description of how you validated changes - Added unit tests in `email-identity.test.ts` to verify that the ARN is correctly parsed and the resulting `IEmailIdentity` behaves as expected. ### 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 87e1add commit 72ee4a7

File tree

13 files changed

+821
-1
lines changed

13 files changed

+821
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.email-identity-from-arn.js.snapshot/EmailIdentityFromArnIntegDefaultTestDeployAssertCC4631C7.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.email-identity-from-arn.js.snapshot/EmailIdentityFromArnIntegDefaultTestDeployAssertCC4631C7.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.email-identity-from-arn.js.snapshot/asset.ab3156800c2f322f16da8bff913172139189a387dd64a4e622f82a790561fd4d/index.py

Lines changed: 31 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.email-identity-from-arn.js.snapshot/cdk-ses-email-identity-from-arn-integ.assets.json

Lines changed: 34 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,265 @@
1+
{
2+
"Resources": {
3+
"HostedZoneDB99F866": {
4+
"Type": "AWS::Route53::HostedZone",
5+
"Properties": {
6+
"Name": "cdk.dev."
7+
}
8+
},
9+
"EmailIdentityDkimDnsToken1BA32ACB3": {
10+
"Type": "AWS::Route53::RecordSet",
11+
"Properties": {
12+
"HostedZoneId": {
13+
"Ref": "HostedZoneDB99F866"
14+
},
15+
"Name": {
16+
"Fn::GetAtt": [
17+
"EmailIdentity7187767D",
18+
"DkimDNSTokenName1"
19+
]
20+
},
21+
"ResourceRecords": [
22+
{
23+
"Fn::GetAtt": [
24+
"EmailIdentity7187767D",
25+
"DkimDNSTokenValue1"
26+
]
27+
}
28+
],
29+
"TTL": "1800",
30+
"Type": "CNAME"
31+
}
32+
},
33+
"EmailIdentityDkimDnsToken2BBEBB8EC": {
34+
"Type": "AWS::Route53::RecordSet",
35+
"Properties": {
36+
"HostedZoneId": {
37+
"Ref": "HostedZoneDB99F866"
38+
},
39+
"Name": {
40+
"Fn::GetAtt": [
41+
"EmailIdentity7187767D",
42+
"DkimDNSTokenName2"
43+
]
44+
},
45+
"ResourceRecords": [
46+
{
47+
"Fn::GetAtt": [
48+
"EmailIdentity7187767D",
49+
"DkimDNSTokenValue2"
50+
]
51+
}
52+
],
53+
"TTL": "1800",
54+
"Type": "CNAME"
55+
}
56+
},
57+
"EmailIdentityDkimDnsToken3BB5E8A49": {
58+
"Type": "AWS::Route53::RecordSet",
59+
"Properties": {
60+
"HostedZoneId": {
61+
"Ref": "HostedZoneDB99F866"
62+
},
63+
"Name": {
64+
"Fn::GetAtt": [
65+
"EmailIdentity7187767D",
66+
"DkimDNSTokenName3"
67+
]
68+
},
69+
"ResourceRecords": [
70+
{
71+
"Fn::GetAtt": [
72+
"EmailIdentity7187767D",
73+
"DkimDNSTokenValue3"
74+
]
75+
}
76+
],
77+
"TTL": "1800",
78+
"Type": "CNAME"
79+
}
80+
},
81+
"EmailIdentity7187767D": {
82+
"Type": "AWS::SES::EmailIdentity",
83+
"Properties": {
84+
"EmailIdentity": "cdk.dev",
85+
"MailFromAttributes": {
86+
"MailFromDomain": "mail.cdk.dev"
87+
}
88+
}
89+
},
90+
"EmailIdentityMailFromMxRecordCEAAECD0": {
91+
"Type": "AWS::Route53::RecordSet",
92+
"Properties": {
93+
"HostedZoneId": {
94+
"Ref": "HostedZoneDB99F866"
95+
},
96+
"Name": "mail.cdk.dev.",
97+
"ResourceRecords": [
98+
{
99+
"Fn::Join": [
100+
"",
101+
[
102+
"10 feedback-smtp.",
103+
{
104+
"Ref": "AWS::Region"
105+
},
106+
".amazonses.com"
107+
]
108+
]
109+
}
110+
],
111+
"TTL": "1800",
112+
"Type": "MX"
113+
}
114+
},
115+
"EmailIdentityMailFromTxtRecordE6B5E5D0": {
116+
"Type": "AWS::Route53::RecordSet",
117+
"Properties": {
118+
"HostedZoneId": {
119+
"Ref": "HostedZoneDB99F866"
120+
},
121+
"Name": "mail.cdk.dev.",
122+
"ResourceRecords": [
123+
"\"v=spf1 include:amazonses.com ~all\""
124+
],
125+
"TTL": "1800",
126+
"Type": "TXT"
127+
}
128+
},
129+
"FunctionServiceRole675BB04A": {
130+
"Type": "AWS::IAM::Role",
131+
"Properties": {
132+
"AssumeRolePolicyDocument": {
133+
"Statement": [
134+
{
135+
"Action": "sts:AssumeRole",
136+
"Effect": "Allow",
137+
"Principal": {
138+
"Service": "lambda.amazonaws.com"
139+
}
140+
}
141+
],
142+
"Version": "2012-10-17"
143+
},
144+
"ManagedPolicyArns": [
145+
{
146+
"Fn::Join": [
147+
"",
148+
[
149+
"arn:",
150+
{
151+
"Ref": "AWS::Partition"
152+
},
153+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
154+
]
155+
]
156+
}
157+
]
158+
}
159+
},
160+
"FunctionServiceRoleDefaultPolicy2F49994A": {
161+
"Type": "AWS::IAM::Policy",
162+
"Properties": {
163+
"PolicyDocument": {
164+
"Statement": [
165+
{
166+
"Action": [
167+
"ses:SendEmail",
168+
"ses:SendRawEmail"
169+
],
170+
"Effect": "Allow",
171+
"Resource": {
172+
"Fn::Join": [
173+
"",
174+
[
175+
"arn:",
176+
{
177+
"Ref": "AWS::Partition"
178+
},
179+
":ses:",
180+
{
181+
"Ref": "AWS::Region"
182+
},
183+
":",
184+
{
185+
"Ref": "AWS::AccountId"
186+
},
187+
":identity/",
188+
{
189+
"Ref": "EmailIdentity7187767D"
190+
}
191+
]
192+
]
193+
}
194+
}
195+
],
196+
"Version": "2012-10-17"
197+
},
198+
"PolicyName": "FunctionServiceRoleDefaultPolicy2F49994A",
199+
"Roles": [
200+
{
201+
"Ref": "FunctionServiceRole675BB04A"
202+
}
203+
]
204+
}
205+
},
206+
"Function76856677": {
207+
"Type": "AWS::Lambda::Function",
208+
"Properties": {
209+
"Code": {
210+
"S3Bucket": {
211+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
212+
},
213+
"S3Key": "ab3156800c2f322f16da8bff913172139189a387dd64a4e622f82a790561fd4d.zip"
214+
},
215+
"FunctionName": "email-sending-lambda-from-arn",
216+
"Handler": "index.lambda_handler",
217+
"Role": {
218+
"Fn::GetAtt": [
219+
"FunctionServiceRole675BB04A",
220+
"Arn"
221+
]
222+
},
223+
"Runtime": "python3.11"
224+
},
225+
"DependsOn": [
226+
"FunctionServiceRoleDefaultPolicy2F49994A",
227+
"FunctionServiceRole675BB04A"
228+
]
229+
}
230+
},
231+
"Parameters": {
232+
"BootstrapVersion": {
233+
"Type": "AWS::SSM::Parameter::Value<String>",
234+
"Default": "/cdk-bootstrap/hnb659fds/version",
235+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
236+
}
237+
},
238+
"Rules": {
239+
"CheckBootstrapVersion": {
240+
"Assertions": [
241+
{
242+
"Assert": {
243+
"Fn::Not": [
244+
{
245+
"Fn::Contains": [
246+
[
247+
"1",
248+
"2",
249+
"3",
250+
"4",
251+
"5"
252+
],
253+
{
254+
"Ref": "BootstrapVersion"
255+
}
256+
]
257+
}
258+
]
259+
},
260+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
261+
}
262+
]
263+
}
264+
}
265+
}

packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/integ.email-identity-from-arn.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.

0 commit comments

Comments
 (0)