-
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
feat(core): add easy importValue to CfnOutput #11368
Conversation
To transport values across Stages, users need to construct their own `{ Fn::ImportValue }` expressions, as we cannot properly do this for them in order to keep Stages deterministic and isolated. Add an expression constructor to make this API easier to use. Resolves #11360.
return Fn.importValue(Lazy.stringValue({ | ||
produce: () => { | ||
if (!this._exportName) { | ||
throw new Error(`Add an exportName to the CfnOutput at '${this.node.path}' in order to use 'output.importValue'`); |
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.
Can't we auto-allocate an export name in this case (similar to the one we allocate for auto-refs)?
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.
We could, but I'm not 100% comfortable doing that yet. Doesn't seem too onerous to start by expecting people to provide a name.
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.
ok
/** | ||
* Return the `Fn.importValue` expression to import this value into another stack | ||
* | ||
* The returned value should not be used in the same stack, but in a |
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.
Can we test that this is referenced in the same stack and fail early?
return Fn.importValue(Lazy.stringValue({ | ||
produce: () => { | ||
if (!this._exportName) { | ||
throw new Error(`Add an exportName to the CfnOutput at '${this.node.path}' in order to use 'output.importValue'`); |
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.
ok
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 master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
To transport values across Stages, users need to construct their
own
{ Fn::ImportValue }
expressions, as we cannot properly do thisfor them in order to keep Stages deterministic and isolated.
Add an expression constructor to make this API easier to use.
Resolves #11360.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license