Skip to content

Commit 8c76349

Browse files
chore: add integ test for cross-region refs (#27118)
Adds integration test for using cross-region reference custom resource handlers. Currently cross region multi-stack tests in `IntegTest` are not super well supported so assertions aren't a great option but a successful stack deploy and delete does indicate success of the CRs currently. Closes #27069 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 480b1f5 commit 8c76349

File tree

15 files changed

+1545
-0
lines changed

15 files changed

+1545
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"version": "34.0.0",
3+
"files": {
4+
"863f318b36ec4666a297aefb6cf8390c2f0bb6ec4ef3ae0040a63a0727f50ccf": {
5+
"source": {
6+
"path": "asset.863f318b36ec4666a297aefb6cf8390c2f0bb6ec4ef3ae0040a63a0727f50ccf",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-us-east-2": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-2",
12+
"objectKey": "863f318b36ec4666a297aefb6cf8390c2f0bb6ec4ef3ae0040a63a0727f50ccf.zip",
13+
"region": "us-east-2",
14+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-2"
15+
}
16+
}
17+
},
18+
"f9d53aeabbd76f4bab5deb04ef649d0ebf6875c5bd7bba157d72aa0a8003ac46": {
19+
"source": {
20+
"path": "CrossRegionRefConsumerInteg.template.json",
21+
"packaging": "file"
22+
},
23+
"destinations": {
24+
"current_account-us-east-2": {
25+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-2",
26+
"objectKey": "f9d53aeabbd76f4bab5deb04ef649d0ebf6875c5bd7bba157d72aa0a8003ac46.json",
27+
"region": "us-east-2",
28+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-2"
29+
}
30+
}
31+
}
32+
},
33+
"dockerImages": {}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"Resources": {
3+
"SomeParameterMirroredE2D8F3B8": {
4+
"Type": "AWS::SSM::Parameter",
5+
"Properties": {
6+
"Name": "KNOWN_PARAMETER_NAME",
7+
"Type": "String",
8+
"Value": {
9+
"Fn::GetAtt": [
10+
"ExportsReader8B249524",
11+
"/cdk/exports/CrossRegionRefConsumerInteg/CrossRegionRefProducerInteguseast1FnGetAttSomeParameterB1EDD45BValue399DD9D8"
12+
]
13+
}
14+
}
15+
},
16+
"ExportsReader8B249524": {
17+
"Type": "Custom::CrossRegionExportReader",
18+
"Properties": {
19+
"ServiceToken": {
20+
"Fn::GetAtt": [
21+
"CustomCrossRegionExportReaderCustomResourceProviderHandler46647B68",
22+
"Arn"
23+
]
24+
},
25+
"ReaderProps": {
26+
"region": "us-east-2",
27+
"prefix": "CrossRegionRefConsumerInteg",
28+
"imports": {
29+
"/cdk/exports/CrossRegionRefConsumerInteg/CrossRegionRefProducerInteguseast1FnGetAttSomeParameterB1EDD45BValue399DD9D8": "{{resolve:ssm:/cdk/exports/CrossRegionRefConsumerInteg/CrossRegionRefProducerInteguseast1FnGetAttSomeParameterB1EDD45BValue399DD9D8}}"
30+
}
31+
}
32+
},
33+
"UpdateReplacePolicy": "Delete",
34+
"DeletionPolicy": "Delete"
35+
},
36+
"CustomCrossRegionExportReaderCustomResourceProviderRole10531BBD": {
37+
"Type": "AWS::IAM::Role",
38+
"Properties": {
39+
"AssumeRolePolicyDocument": {
40+
"Version": "2012-10-17",
41+
"Statement": [
42+
{
43+
"Action": "sts:AssumeRole",
44+
"Effect": "Allow",
45+
"Principal": {
46+
"Service": "lambda.amazonaws.com"
47+
}
48+
}
49+
]
50+
},
51+
"ManagedPolicyArns": [
52+
{
53+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
54+
}
55+
],
56+
"Policies": [
57+
{
58+
"PolicyName": "Inline",
59+
"PolicyDocument": {
60+
"Version": "2012-10-17",
61+
"Statement": [
62+
{
63+
"Effect": "Allow",
64+
"Resource": {
65+
"Fn::Join": [
66+
"",
67+
[
68+
"arn:aws:ssm:us-east-2:",
69+
{
70+
"Ref": "AWS::AccountId"
71+
},
72+
":parameter/cdk/exports/CrossRegionRefConsumerInteg/*"
73+
]
74+
]
75+
},
76+
"Action": [
77+
"ssm:AddTagsToResource",
78+
"ssm:RemoveTagsFromResource",
79+
"ssm:GetParameters"
80+
]
81+
}
82+
]
83+
}
84+
}
85+
]
86+
}
87+
},
88+
"CustomCrossRegionExportReaderCustomResourceProviderHandler46647B68": {
89+
"Type": "AWS::Lambda::Function",
90+
"Properties": {
91+
"Code": {
92+
"S3Bucket": {
93+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-2"
94+
},
95+
"S3Key": "863f318b36ec4666a297aefb6cf8390c2f0bb6ec4ef3ae0040a63a0727f50ccf.zip"
96+
},
97+
"Timeout": 900,
98+
"MemorySize": 128,
99+
"Handler": "__entrypoint__.handler",
100+
"Role": {
101+
"Fn::GetAtt": [
102+
"CustomCrossRegionExportReaderCustomResourceProviderRole10531BBD",
103+
"Arn"
104+
]
105+
},
106+
"Runtime": "nodejs18.x"
107+
},
108+
"DependsOn": [
109+
"CustomCrossRegionExportReaderCustomResourceProviderRole10531BBD"
110+
]
111+
}
112+
},
113+
"Parameters": {
114+
"BootstrapVersion": {
115+
"Type": "AWS::SSM::Parameter::Value<String>",
116+
"Default": "/cdk-bootstrap/hnb659fds/version",
117+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
118+
}
119+
},
120+
"Rules": {
121+
"CheckBootstrapVersion": {
122+
"Assertions": [
123+
{
124+
"Assert": {
125+
"Fn::Not": [
126+
{
127+
"Fn::Contains": [
128+
[
129+
"1",
130+
"2",
131+
"3",
132+
"4",
133+
"5"
134+
],
135+
{
136+
"Ref": "BootstrapVersion"
137+
}
138+
]
139+
}
140+
]
141+
},
142+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
143+
}
144+
]
145+
}
146+
}
147+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"version": "34.0.0",
3+
"files": {
4+
"1a067234d252533a95ecaaccd4b3e821e6a69df0b03b918b596fc5a40eeb71a1": {
5+
"source": {
6+
"path": "asset.1a067234d252533a95ecaaccd4b3e821e6a69df0b03b918b596fc5a40eeb71a1",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-us-east-1": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1",
12+
"objectKey": "1a067234d252533a95ecaaccd4b3e821e6a69df0b03b918b596fc5a40eeb71a1.zip",
13+
"region": "us-east-1",
14+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1"
15+
}
16+
}
17+
},
18+
"de0260269768be40f7cca7a538a2cd2a560a133f1e3d18b60a42d270ecb20120": {
19+
"source": {
20+
"path": "CrossRegionRefProducerInteg.template.json",
21+
"packaging": "file"
22+
},
23+
"destinations": {
24+
"current_account-us-east-1": {
25+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1",
26+
"objectKey": "de0260269768be40f7cca7a538a2cd2a560a133f1e3d18b60a42d270ecb20120.json",
27+
"region": "us-east-1",
28+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1"
29+
}
30+
}
31+
}
32+
},
33+
"dockerImages": {}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"Resources": {
3+
"SomeParameterB1EDD45B": {
4+
"Type": "AWS::SSM::Parameter",
5+
"Properties": {
6+
"Name": "KNOWN_PARAMETER_NAME",
7+
"Type": "String",
8+
"Value": "MY_PARAMETER_VALUE"
9+
}
10+
},
11+
"ExportsWriteruseast2828FA26B86FBEFA7": {
12+
"Type": "Custom::CrossRegionExportWriter",
13+
"Properties": {
14+
"ServiceToken": {
15+
"Fn::GetAtt": [
16+
"CustomCrossRegionExportWriterCustomResourceProviderHandlerD8786E8A",
17+
"Arn"
18+
]
19+
},
20+
"WriterProps": {
21+
"region": "us-east-2",
22+
"exports": {
23+
"/cdk/exports/CrossRegionRefConsumerInteg/CrossRegionRefProducerInteguseast1FnGetAttSomeParameterB1EDD45BValue399DD9D8": {
24+
"Fn::GetAtt": [
25+
"SomeParameterB1EDD45B",
26+
"Value"
27+
]
28+
}
29+
}
30+
}
31+
},
32+
"UpdateReplacePolicy": "Delete",
33+
"DeletionPolicy": "Delete"
34+
},
35+
"CustomCrossRegionExportWriterCustomResourceProviderRoleC951B1E1": {
36+
"Type": "AWS::IAM::Role",
37+
"Properties": {
38+
"AssumeRolePolicyDocument": {
39+
"Version": "2012-10-17",
40+
"Statement": [
41+
{
42+
"Action": "sts:AssumeRole",
43+
"Effect": "Allow",
44+
"Principal": {
45+
"Service": "lambda.amazonaws.com"
46+
}
47+
}
48+
]
49+
},
50+
"ManagedPolicyArns": [
51+
{
52+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
53+
}
54+
],
55+
"Policies": [
56+
{
57+
"PolicyName": "Inline",
58+
"PolicyDocument": {
59+
"Version": "2012-10-17",
60+
"Statement": [
61+
{
62+
"Effect": "Allow",
63+
"Resource": [
64+
{
65+
"Fn::Join": [
66+
"",
67+
[
68+
"arn:aws:ssm:us-east-2:",
69+
{
70+
"Ref": "AWS::AccountId"
71+
},
72+
":parameter/cdk/exports/*"
73+
]
74+
]
75+
}
76+
],
77+
"Action": [
78+
"ssm:DeleteParameters",
79+
"ssm:ListTagsForResource",
80+
"ssm:GetParameters",
81+
"ssm:PutParameter"
82+
]
83+
}
84+
]
85+
}
86+
}
87+
]
88+
}
89+
},
90+
"CustomCrossRegionExportWriterCustomResourceProviderHandlerD8786E8A": {
91+
"Type": "AWS::Lambda::Function",
92+
"Properties": {
93+
"Code": {
94+
"S3Bucket": {
95+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1"
96+
},
97+
"S3Key": "1a067234d252533a95ecaaccd4b3e821e6a69df0b03b918b596fc5a40eeb71a1.zip"
98+
},
99+
"Timeout": 900,
100+
"MemorySize": 128,
101+
"Handler": "__entrypoint__.handler",
102+
"Role": {
103+
"Fn::GetAtt": [
104+
"CustomCrossRegionExportWriterCustomResourceProviderRoleC951B1E1",
105+
"Arn"
106+
]
107+
},
108+
"Runtime": "nodejs18.x"
109+
},
110+
"DependsOn": [
111+
"CustomCrossRegionExportWriterCustomResourceProviderRoleC951B1E1"
112+
]
113+
}
114+
},
115+
"Parameters": {
116+
"BootstrapVersion": {
117+
"Type": "AWS::SSM::Parameter::Value<String>",
118+
"Default": "/cdk-bootstrap/hnb659fds/version",
119+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
120+
}
121+
},
122+
"Rules": {
123+
"CheckBootstrapVersion": {
124+
"Assertions": [
125+
{
126+
"Assert": {
127+
"Fn::Not": [
128+
{
129+
"Fn::Contains": [
130+
[
131+
"1",
132+
"2",
133+
"3",
134+
"4",
135+
"5"
136+
],
137+
{
138+
"Ref": "BootstrapVersion"
139+
}
140+
]
141+
}
142+
]
143+
},
144+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
145+
}
146+
]
147+
}
148+
}
149+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "34.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "CrossRegionSSMReferenceTestDefaultTestDeployAssert2460BCA3.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}

0 commit comments

Comments
 (0)