Skip to content

Fix: CFn: mappings with references #11539

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

Merged
merged 3 commits into from
Sep 20, 2024
Merged

Fix: CFn: mappings with references #11539

merged 3 commits into from
Sep 20, 2024

Conversation

simonrw
Copy link
Contributor

@simonrw simonrw commented Sep 18, 2024

Motivation

A customer presented an error which involved a FindInMap in a Condition. The FindInMap uses Refs for its map and top level keys, which raised an error:

    return mappings[map_name][top_level_key][second_level_key]
           ~~~~~~~~^^^^^^^^^^
TypeError: unhashable type: 'dict'

Changes

  • Implement the fix by resolving the ref from the template parameters
  • Improve error handling on invalid input

@simonrw simonrw added the semver: patch Non-breaking changes which can be included in patch releases label Sep 18, 2024
@simonrw simonrw self-assigned this Sep 18, 2024
Copy link

github-actions bot commented Sep 18, 2024

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 34m 31s ⏱️ - 2m 42s
3 441 tests +2  3 043 ✅ +2  398 💤 ±0  0 ❌ ±0 
3 443 runs  +2  3 043 ✅ +2  400 💤 ±0  0 ❌ ±0 

Results for commit c3b2a25. ± Comparison against base commit b770a27.

♻️ This comment has been updated with latest results.

@simonrw simonrw force-pushed the fix/cfn/findinmap-ref-key branch from 5960836 to 52d90ec Compare September 19, 2024 08:22
@simonrw simonrw marked this pull request as ready for review September 19, 2024 16:51
Copy link
Member

@pinzon pinzon Sep 20, 2024

Choose a reason for hiding this comment

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

It's good that our template deployer now supports many CloudFormation features. In the future we should consider refactoring this function to improve readability and maintainability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely, if we are going to do the same level of input valuation and error reporting that this one does

Comment on lines 174 to 175
describe_res = aws_client.sns.get_topic_attributes(TopicArn=topic_arn)
snapshot.match("topic-attributes", describe_res)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: These lines seem unnecessary for the test. Maybe a positive and a negative deployment could have more value in this situation .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks!

Copy link
Member

@pinzon pinzon left a comment

Choose a reason for hiding this comment

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

LGTM. Just some nits.

@simonrw simonrw force-pushed the fix/cfn/findinmap-ref-key branch from 52d90ec to 8449252 Compare September 20, 2024 11:11
@simonrw simonrw merged commit 5271fc0 into master Sep 20, 2024
34 checks passed
@simonrw simonrw deleted the fix/cfn/findinmap-ref-key branch September 20, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants