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

aws-cdk: Fn.find_in_map default_value not working in version 2.92.0 #26843

Closed
drobbins-ancile opened this issue Aug 22, 2023 · 4 comments
Closed
Labels
@aws-cdk/aws-codebuild Related to AWS CodeBuild bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@drobbins-ancile
Copy link

Describe the bug

I am attempting to use the new default_value behavior that was added in 2.91.0 (#26543) and receiving TypeError: Fn.find_in_map() got an unexpected keyword argument 'default_value' when synthesizing in an AWS CodeBuild project.

Code:

"SUMO_HTTP_ENDPOINT": Fn.find_in_map(
    map_name="SumoLogEndpointMapping",
    top_level_key=Fn.sub("${AWS::Region}"),
    second_level_key=environment_identifier,
    default_value="https://collectors.sumologic.com/receiver/v1/http/ZaVnC4dhaV1w186NMo7tSCtg2WkVlLJuOnn3fLHQVBNG_7-rAMTESF8WXfvgvI9JNThMJXDtarakXHXiikuTsWmTbtuxWNR-7KcsyoYupy7uowmxO7s_eA==",
),

The build project shows the CDK version:

cdk --version
2.92.0 (build bf62e55)

I was asked to create this issue by AWS Support as they were able to replicate the error message as well.

Expected Behavior

The template successfully synthesizes using the mapping with a default value.

Current Behavior

Synthesize fails with TypeError: Fn.find_in_map() got an unexpected keyword argument 'default_value'.

Reproduction Steps

Create a mapping:

  cdk.CfnMapping(
      self,
      "SumoLogEndpointMapping",
      mapping={
          "us-east-1": {
              "Dev": "https://collectors.sumologic.com/receiver/v1/http/ZaVnC4dhaV2zVTIbTl6Q5l5Y5y6BldZgrQTXxwNS7uobzEOcGhKUftWzW9cwXEzHjl8AKpgAvzGmKeVVhy2uK1PgIahFv4Ge1_VSWgQZ36xc7Uj108obQQ==",
	}
      },
  )

Attempt to set a value using Fn.find_in_map:

  "SUMO_HTTP_ENDPOINT": Fn.find_in_map(
      map_name="SumoLogEndpointMapping",
      top_level_key=Fn.sub("${AWS::Region}"),
      second_level_key=environment_identifier,
      default_value="https://collectors.sumologic.com/receiver/v1/http/ZaVnC4dhaV1w186NMo7tSCtg2WkVlLJuOnn3fLHQVBNG_7-rAMTESF8WXfvgvI9JNThMJXDtarakXHXiikuTsWmTbtuxWNR-7KcsyoYupy7elomxO7s_eA==",
  ),

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.92.0 (build bf62e55)

Framework Version

No response

Node.js Version

16

OS

AWS Linux (CodeBuild aws/codebuild/standard:6.0)

Language

Python

Language Version

3.10

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 Aug 22, 2023
@github-actions github-actions bot added the @aws-cdk/aws-codebuild Related to AWS CodeBuild label Aug 22, 2023
@peterwoodworth
Copy link
Contributor

peterwoodworth commented Aug 22, 2023

Is this only occurring for you in Codebuild? If so, are you sure that your codebuild aws-cdk-lib version is at 2.92.0 as well? You would need to check that the dependencies are actually using the new version, it's not enough for just the CLI to be at 2.92.0 depending on your build commands.

If that isn't an issue, please provide a working reproduction which I'd be able to copy+paste and reproduce the error with, or provide a repository

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 22, 2023
@scanlonp
Copy link
Contributor

Additionally, does the error still occur if you use CfnMapping.find_in_map() instead of Fn.find_in_map()?

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Aug 22, 2023
@drobbins-ancile
Copy link
Author

Is this only occurring for you in Codebuild? If so, are you sure that your codebuild aws-cdk-lib version is at 2.92.0 as well? You would need to check that the dependencies are actually using the new version, it's not enough for just the CLI to be at 2.92.0 depending on your build commands.

That was it. Not sure why pip was installing an older version as we did not specify a version in the requirements.txt file but it seems to have corrected itself.

Thanks for your time.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codebuild Related to AWS CodeBuild bug This issue is a bug. 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

3 participants