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

CfnMapping.find_in_map: Template Validation Error When Optional default_value is not specified. #27987

Closed
drobbins-ancile opened this issue Nov 14, 2023 · 2 comments
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@drobbins-ancile
Copy link

drobbins-ancile commented Nov 14, 2023

Describe the bug

The following code synthesizes successfully but produces a template error in the CloudFormation console:

ipset_mapping = CfnMapping(
    self,
    "IpSetMapping",
    lazy=True,
    mapping={
        "us-east-1": {
            "Prod": "arn:aws:wafv2:12345",
        }
	}
)


ipset_mapping.find_in_map(
  Fn.sub("${AWS::Region}"),
  environment.value_as_string
)

According to the docs the default_value parameter is optional.

If the default_value parameter is specified the synthesized template deploys successfully.

Expected Behavior

The synthesized cloudformation template can be deployed without error.

Current Behavior

An error message is displayed in the CloudFormation console:

Template error: every Fn::FindInMap object requires three parameters, the map name, map key and the attribute for return value.

Reproduction Steps

  1. Create a mapping and reference a value in the mapping using the find_in_map method without specifying the default_value parameter.
  2. Attempt to deploy the synthesized template

Possible Solution

Either account for the cloudformation API requirement by making the default_value parameter required or fix the API to support this parameter being optional.

Additional Information/Context

No response

CDK CLI Version

2.106.1 (build a2e5f65)

Framework Version

No response

Node.js Version

v21.1.0

OS

Mac

Language

Python

Language Version

3.12.0

Other information

No response

@drobbins-ancile drobbins-ancile added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 14, 2023
@github-actions github-actions bot added the @aws-cdk/aws-cloudformation Related to AWS CloudFormation label Nov 14, 2023
@pahud
Copy link
Contributor

pahud commented Nov 14, 2023

I didn't get it.

Are you able to deploy this sample and see the output as below?

image

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 14, 2023
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants