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

(core): CfnMapping in one stack, use value in another #18920

Closed
rix0rrr opened this issue Feb 10, 2022 · 4 comments · Fixed by #20616
Closed

(core): CfnMapping in one stack, use value in another #18920

rix0rrr opened this issue Feb 10, 2022 · 4 comments · Fixed by #20616
Assignees
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@rix0rrr
Copy link
Contributor

rix0rrr commented Feb 10, 2022

What is the problem?

CfnMapping in one stack, use value in another.

Will lead to "unknown mapping" error in 2nd stack.

@rix0rrr rix0rrr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 10, 2022
@github-actions github-actions bot added the @aws-cdk/core Related to core CDK functionality label Feb 10, 2022
@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort p1 and removed @aws-cdk/core Related to core CDK functionality labels Feb 10, 2022
@rix0rrr rix0rrr removed their assignment Feb 10, 2022
@kaizencc kaizencc removed the needs-triage This issue or PR still needs to be triaged. label Mar 11, 2022
@rix0rrr
Copy link
Contributor Author

rix0rrr commented Mar 14, 2022

Example:

const stack1 = new Stack(app, 'Stack1');
const mapping = new CfnMapping(stack1, 'Mapping', {
  mapping: {
    'boo': { 
       'bah': 'hello'
    },
  },
});


const stack2 = new Stack(app, 'Stack2');
new CfnOutput(stack2, 'Output', {
  value: mapping.findInMap('boo', 'bah'),
});

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Mar 14, 2022

Current result: generates a { Fn::FindInMap } in Stack2 where the mapping does not exist.

Simplest desired result: generate the same mapping in Stack2.

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Mar 14, 2022

Solution: turn the result value of findInMap into a Token, that on-resolve can add a copy of itself to the consuming stack.

@comcalvi comcalvi self-assigned this Jun 2, 2022
@mergify mergify bot closed this as completed in #20616 Jun 15, 2022
mergify bot pushed a commit that referenced this issue Jun 15, 2022
Creating a `CfnMapping` in one stack and then using `findInMap()` in another stack will result in an error at deploy time because the `findInMap()` will turn into a `Fn::FindInMap` that searches for a mapping that does not exist. This change copies the mapping to any stack that references it, even if it is not defined.

Closes #18920.

----

### 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

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] 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*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

daschaa pushed a commit to daschaa/aws-cdk that referenced this issue Jul 9, 2022
Creating a `CfnMapping` in one stack and then using `findInMap()` in another stack will result in an error at deploy time because the `findInMap()` will turn into a `Fn::FindInMap` that searches for a mapping that does not exist. This change copies the mapping to any stack that references it, even if it is not defined.

Closes aws#18920.

----

### 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

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] 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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants