Skip to content

Commit 3ddb8cf

Browse files
authored
fix(core): cross stack references to string lists break (#22873)
Previously only strings could be referenced across stacks, due to a CloudFormation requirement that all `Output`s evaluate to strings. This PR allows string lists to be referenced across stacks, like [VpcEndpoint DnsEntries](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html#aws-resource-ec2-vpcendpoint-return-values), by wrapping the exports / imports in `Fn::Split`s and `Fn::Join`s. This does not work across environments. This also makes `ssm.StringListParameter` use `Fn.split(value)` instead of `value.split()`. This is part of the fix to #21682. Cross-env support will be added in a future PR. Adds a new public method, `exportListValue()`, to the `Stack` class to avoid breaking changes. Implementation requires adding type hints to `IResolvable` and modifying the codegen to populate them correctly. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 2bd1e41 commit 3ddb8cf

28 files changed

+1675
-47
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"22.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "22.0.0",
3+
"files": {
4+
"0fe7f73285a0ff152665f28743981914632b5c05b361126f8af577515c058bdc": {
5+
"source": {
6+
"path": "consumer.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "0fe7f73285a0ff152665f28743981914632b5c05b361126f8af577515c058bdc.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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"Resources": {
3+
"GetAtt0B6ACA40": {
4+
"Type": "AWS::SSM::Parameter",
5+
"Properties": {
6+
"Type": "StringList",
7+
"Value": {
8+
"Fn::Join": [
9+
",",
10+
{
11+
"Fn::Split": [
12+
"||",
13+
{
14+
"Fn::ImportValue": "producer:ExportsOutputFnGetAttendpointE7B9679BDnsEntries62080A34"
15+
}
16+
]
17+
}
18+
]
19+
}
20+
}
21+
},
22+
"Ref47C32AF2": {
23+
"Type": "AWS::SSM::Parameter",
24+
"Properties": {
25+
"Type": "StringList",
26+
"Value": {
27+
"Fn::Join": [
28+
",",
29+
{
30+
"Fn::Split": [
31+
"||",
32+
{
33+
"Fn::ImportValue": "producer:ExportsOutputRefstringListParam77B646D6"
34+
}
35+
]
36+
}
37+
]
38+
}
39+
}
40+
},
41+
"ManualEB2ECD12": {
42+
"Type": "AWS::SSM::Parameter",
43+
"Properties": {
44+
"Type": "StringList",
45+
"Value": {
46+
"Fn::Join": [
47+
",",
48+
{
49+
"Fn::Split": [
50+
"||",
51+
{
52+
"Fn::ImportValue": "ManualExport"
53+
}
54+
]
55+
}
56+
]
57+
}
58+
}
59+
}
60+
},
61+
"Parameters": {
62+
"BootstrapVersion": {
63+
"Type": "AWS::SSM::Parameter::Value<String>",
64+
"Default": "/cdk-bootstrap/hnb659fds/version",
65+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
66+
}
67+
},
68+
"Rules": {
69+
"CheckBootstrapVersion": {
70+
"Assertions": [
71+
{
72+
"Assert": {
73+
"Fn::Not": [
74+
{
75+
"Fn::Contains": [
76+
[
77+
"1",
78+
"2",
79+
"3",
80+
"4",
81+
"5"
82+
],
83+
{
84+
"Ref": "BootstrapVersion"
85+
}
86+
]
87+
}
88+
]
89+
},
90+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
91+
}
92+
]
93+
}
94+
}
95+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "22.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "crossregionreferencesDefaultTestDeployAssertAB7415FD.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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "22.0.0",
3+
"testCases": {
4+
"cross-region-references/DefaultTest": {
5+
"stacks": [
6+
"producer",
7+
"consumer"
8+
],
9+
"stackUpdateWorkflow": false,
10+
"assertionStack": "cross-region-references/DefaultTest/DeployAssert",
11+
"assertionStackName": "crossregionreferencesDefaultTestDeployAssertAB7415FD"
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)