-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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*
- Loading branch information
Showing
28 changed files
with
1,675 additions
and
47 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...s/@aws-cdk/aws-ec2/test/integ.core-cross-stack-string-list-references.js.snapshot/cdk.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":"22.0.0"} |
19 changes: 19 additions & 0 deletions
19
...s-ec2/test/integ.core-cross-stack-string-list-references.js.snapshot/consumer.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "22.0.0", | ||
"files": { | ||
"0fe7f73285a0ff152665f28743981914632b5c05b361126f8af577515c058bdc": { | ||
"source": { | ||
"path": "consumer.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "0fe7f73285a0ff152665f28743981914632b5c05b361126f8af577515c058bdc.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
95 changes: 95 additions & 0 deletions
95
...ec2/test/integ.core-cross-stack-string-list-references.js.snapshot/consumer.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"Resources": { | ||
"GetAtt0B6ACA40": { | ||
"Type": "AWS::SSM::Parameter", | ||
"Properties": { | ||
"Type": "StringList", | ||
"Value": { | ||
"Fn::Join": [ | ||
",", | ||
{ | ||
"Fn::Split": [ | ||
"||", | ||
{ | ||
"Fn::ImportValue": "producer:ExportsOutputFnGetAttendpointE7B9679BDnsEntries62080A34" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"Ref47C32AF2": { | ||
"Type": "AWS::SSM::Parameter", | ||
"Properties": { | ||
"Type": "StringList", | ||
"Value": { | ||
"Fn::Join": [ | ||
",", | ||
{ | ||
"Fn::Split": [ | ||
"||", | ||
{ | ||
"Fn::ImportValue": "producer:ExportsOutputRefstringListParam77B646D6" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"ManualEB2ECD12": { | ||
"Type": "AWS::SSM::Parameter", | ||
"Properties": { | ||
"Type": "StringList", | ||
"Value": { | ||
"Fn::Join": [ | ||
",", | ||
{ | ||
"Fn::Split": [ | ||
"||", | ||
{ | ||
"Fn::ImportValue": "ManualExport" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...t-references.js.snapshot/crossregionreferencesDefaultTestDeployAssertAB7415FD.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "22.0.0", | ||
"files": { | ||
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { | ||
"source": { | ||
"path": "crossregionreferencesDefaultTestDeployAssertAB7415FD.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
36 changes: 36 additions & 0 deletions
36
...references.js.snapshot/crossregionreferencesDefaultTestDeployAssertAB7415FD.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...aws-cdk/aws-ec2/test/integ.core-cross-stack-string-list-references.js.snapshot/integ.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"version": "22.0.0", | ||
"testCases": { | ||
"cross-region-references/DefaultTest": { | ||
"stacks": [ | ||
"producer", | ||
"consumer" | ||
], | ||
"stackUpdateWorkflow": false, | ||
"assertionStack": "cross-region-references/DefaultTest/DeployAssert", | ||
"assertionStackName": "crossregionreferencesDefaultTestDeployAssertAB7415FD" | ||
} | ||
} | ||
} |
Oops, something went wrong.