Skip to content
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

Merged
merged 3 commits into from
Nov 13, 2020

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Nov 9, 2020

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.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

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.
@rix0rrr rix0rrr added the pr-linter/exempt-readme The PR linter will not require README changes label Nov 9, 2020
@rix0rrr rix0rrr requested a review from a team November 9, 2020 11:10
@rix0rrr rix0rrr self-assigned this Nov 9, 2020
@gitpod-io
Copy link

gitpod-io bot commented Nov 9, 2020

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 9, 2020
packages/@aws-cdk/core/lib/cfn-output.ts Outdated Show resolved Hide resolved
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'`);
Copy link
Contributor

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)?

Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link
Contributor

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?

@rix0rrr rix0rrr requested a review from eladb November 12, 2020 16:11
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'`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: a5f922b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Nov 13, 2020

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).

@mergify mergify bot merged commit c71a4e9 into master Nov 13, 2020
@mergify mergify bot deleted the huijbers/output-importvalue branch November 13, 2020 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. pr-linter/exempt-readme The PR linter will not require README changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[cdk-pipelines] Cannot add codepipeline action within an Application Stage
3 participants