-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): cross stack references to string lists break #22873
Conversation
packages/@aws-cdk/aws-cloudformation/test/integ.core-cross-stack-string-list-references.ts
Outdated
Show resolved
Hide resolved
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some polishing but conditionally approved
} else if (Array.isArray(props.value)) { | ||
// `props.value` is a string, but because cross-stack exports allow passing any, | ||
// we need to check for lists here. | ||
throw new Error(`CloudFormation output was given a string list instead of a string at path "${this.node.path}"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this definitely fail in CloudFormation, or does it implicitly join or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it definitely fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template format error: The Value field of every Outputs member must evaluate to a String.
|
||
const importExpr = exportingStack.exportValue(reference); | ||
if (Array.isArray((exportingStack as any).determineImportValue(reference))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not the moment where we would inspect the type hint of reference
?
if (Array.isArray(importValue)) { | ||
throw new Error('Attempted to export a list value from `exportValue()`: use `exportStringListValue()` instead'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason this makes me uneasy. Can you do inspections on the value's type and type hints, before we go to export it, instead?
packages/@aws-cdk/core/lib/stack.ts
Outdated
const importValue = this.determineImportValue(exportedValue); | ||
|
||
if (!Array.isArray(importValue)) { | ||
throw new Error('Attempted to export a string value from `exportStringListValue()`: use `exportValue()` instead'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason this makes me uneasy. Can you do inspections on the value's type and type hints, before we go to export it, instead?
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
1 similar comment
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
@Mergifyio requeue |
✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
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 aws#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*
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 aws#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*
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 aws#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*
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, by wrapping the exports / imports inFn::Split
s andFn::Join
s. This does not work across environments.This also makes
ssm.StringListParameter
useFn.split(value)
instead ofvalue.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 theStack
class to avoid breaking changes.Implementation requires adding type hints to
IResolvable
and modifying the codegen to populate them correctly.All Submissions:
Adding new Unconventional Dependencies:
New Features
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