forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
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 NestedStack list values produces…
… invalid outputs (aws#27233) Referencing a list attribute of a resource defined within a NestedStack synthesizes successfully but the nested stack will fail deployment with the error: ``` Template format error: Every Value member must be a string. ``` This prevents deploying resources such into NestedStack instances if a reference to that resource's list attribute needs to be referenced in a cross-stack context. For example, deploying a `InterfaceVpcEndpoint` instance in a nested stack and attempting to reference its `vpcEndpointDnsEntries` property within a different stack will cause this error. To fix this issue, a similar strategy to `exportStringListValue` is used to join the reference's values into a string and expose that value as the output from the nested stack. The reference to the serialized value is then re-exported as normally needed to hoist it to the top-level parent stack. The final reference that imports the value is then re-written to also deserialize the imported string back to the original list. fixes aws#27233 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Brandon Dahler
committed
Dec 18, 2024
1 parent
87e21d6
commit 8219bff
Showing
17 changed files
with
2,242 additions
and
5 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...ework-integ/test/core/test/integ.nested-stack-references.js.snapshot/Consumer.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
...ork-integ/test/core/test/integ.nested-stack-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,65 @@ | ||
{ | ||
"Resources": { | ||
"ConsumerBucket7FE5DCDD": { | ||
"Type": "AWS::S3::Bucket", | ||
"UpdateReplacePolicy": "Retain", | ||
"DeletionPolicy": "Retain" | ||
} | ||
}, | ||
"Outputs": { | ||
"StringAttribute": { | ||
"Value": { | ||
"Fn::ImportValue": "Producer:ExportsOutputFnGetAttNestorNestedStackNestorNestedStackResourceAE182597OutputsProducerNestorMyVpcEndpointD62A76ADRef29EEC1CA" | ||
} | ||
}, | ||
"ListAttribute": { | ||
"Value": { | ||
"Fn::Join": [ | ||
"$$", | ||
{ | ||
"Fn::Split": [ | ||
"||", | ||
{ | ||
"Fn::ImportValue": "Producer:ExportsOutputFnGetAttNestorNestedStackNestorNestedStackResourceAE182597OutputsProducerNestorMyVpcEndpointD62A76ADDnsEntries65CA1FBE" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"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
...k-references.js.snapshot/NestedStackReferencesDefaultTestDeployAssertFE4F9D3A.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...references.js.snapshot/NestedStackReferencesDefaultTestDeployAssertFE4F9D3A.template.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
...ework-integ/test/core/test/integ.nested-stack-references.js.snapshot/Producer.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
89 changes: 89 additions & 0 deletions
89
...ork-integ/test/core/test/integ.nested-stack-references.js.snapshot/Producer.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,89 @@ | ||
{ | ||
"Resources": { | ||
"NestorNestedStackNestorNestedStackResourceAE182597": { | ||
"Type": "AWS::CloudFormation::Stack", | ||
"Properties": { | ||
"TemplateURL": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"https://s3.", | ||
{ | ||
"Ref": "AWS::Region" | ||
}, | ||
".", | ||
{ | ||
"Ref": "AWS::URLSuffix" | ||
}, | ||
"/", | ||
{ | ||
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" | ||
}, | ||
"/75963f58a8f09248997947c93b9ea053986663d50f7b671d09901915deee5d68.json" | ||
] | ||
] | ||
} | ||
}, | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
} | ||
}, | ||
"Outputs": { | ||
"ExportsOutputFnGetAttNestorNestedStackNestorNestedStackResourceAE182597OutputsProducerNestorMyVpcEndpointD62A76ADRef29EEC1CA": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"NestorNestedStackNestorNestedStackResourceAE182597", | ||
"Outputs.ProducerNestorMyVpcEndpointD62A76ADRef" | ||
] | ||
}, | ||
"Export": { | ||
"Name": "Producer:ExportsOutputFnGetAttNestorNestedStackNestorNestedStackResourceAE182597OutputsProducerNestorMyVpcEndpointD62A76ADRef29EEC1CA" | ||
} | ||
}, | ||
"ExportsOutputFnGetAttNestorNestedStackNestorNestedStackResourceAE182597OutputsProducerNestorMyVpcEndpointD62A76ADDnsEntries65CA1FBE": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"NestorNestedStackNestorNestedStackResourceAE182597", | ||
"Outputs.ProducerNestorMyVpcEndpointD62A76ADDnsEntries" | ||
] | ||
}, | ||
"Export": { | ||
"Name": "Producer:ExportsOutputFnGetAttNestorNestedStackNestorNestedStackResourceAE182597OutputsProducerNestorMyVpcEndpointD62A76ADDnsEntries65CA1FBE" | ||
} | ||
} | ||
}, | ||
"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." | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.