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

Impossible to use pseudo-parameters in CFN Mapping #1363

Closed
rsmogura opened this issue Dec 13, 2018 · 1 comment · Fixed by #2220, #2531 or MechanicalRock/tech-radar#14 · May be fixed by MechanicalRock/cdk-constructs#5 or MechanicalRock/cdk-constructs#6
Assignees
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved.

Comments

@rsmogura
Copy link
Contributor

Hi CDK team,

I recently tried to use following construct to get mapping parameter basing on account and region

let mappings = new cdk.Mapping(this, 'RegionsMap', {
            mapping: {
                "us-west-2": {
                    "000000000000": "..."
                }
            }
        });

mappings.findInMap(new cdk.AwsRegion(), new cdk.AwsAccountId());

However during execution I get exception (https://github.com/awslabs/aws-cdk/blob/master/packages/%40aws-cdk/cdk/lib/cloudformation/mapping.ts#L36) as findInMap tries to check if value is in map.

I wonder if mentioned check could be removed, as syntax with findInMap is shorter and less error prone than new cdk.FnFindInMap.

@eladb
Copy link
Contributor

eladb commented Dec 13, 2018

Makes sense of course. We could use cdk.unresolved to determine if the key is a concrete string or a token like {AWS::Region} and only check existence of the key if it's resolved

@RomainMuller RomainMuller added enhancement @aws-cdk/core Related to core CDK functionality labels Dec 14, 2018
@srchase srchase added feature-request A feature should be added or improved. and removed enhancement labels Jan 3, 2019
@eladb eladb added the bug This issue is a bug. label Mar 4, 2019
@eladb eladb changed the title RFE: Support for pseudo-parameters for Mapping Impossible to use pseudo-parameters in CFN Mapping object Mar 4, 2019
@eladb eladb changed the title Impossible to use pseudo-parameters in CFN Mapping object Impossible to use pseudo-parameters in CFN Mapping Mar 4, 2019
@eladb eladb self-assigned this Apr 2, 2019
eladb pushed a commit that referenced this issue Apr 10, 2019
gate the key existence check by !Token.unresolved
so if tokens are used, the key check will not occur.

fixes #1363
eladb pushed a commit that referenced this issue Apr 10, 2019
…2220)

* fix(core): allow CfnMapping.findInMap to use pseudo functions/params

gate the key existence check by !Token.unresolved
so if tokens are used, the key check will not occur.

fixes #1363
@fulghum fulghum added the effort/small Small work item – less than a day of effort label Apr 15, 2019
@eladb eladb reopened this May 13, 2019
eladb pushed a commit that referenced this issue May 13, 2019
Do not validate existence of second key if the first
key is a token.

Fixes #1363
eladb pushed a commit that referenced this issue May 13, 2019
Do not validate existence of second key if the first
key is a token.

Fixes #1363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment