CloudFormation: Support nested intrinsic functions in Fn::FindInMap#13678
CloudFormation: Support nested intrinsic functions in Fn::FindInMap#13678nik-localstack merged 1 commit intomainfrom
Conversation
LocalStack Community integration with Pro 2 files 2 suites 30m 53s ⏱️ Results for commit 3aefe4c. ♻️ This comment has been updated with latest results. |
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 43m 31s ⏱️ Results for commit 3aefe4c. ♻️ This comment has been updated with latest results. |
Test Results - Alternative Providers585 tests 322 ✅ 17m 43s ⏱️ Results for commit 3aefe4c. ♻️ This comment has been updated with latest results. |
pinzon
left a comment
There was a problem hiding this comment.
Great PR. Thank you for fixing the issue and tackling a todo at the same time. I just have a minor comment for the last test.
| template_2 = { | ||
| "Parameters": { | ||
| "Environment": { | ||
| "Type": "String", | ||
| "Default": "dev", # Changed from "prod" | ||
| } | ||
| }, | ||
| "Mappings": { | ||
| "ComplexMap": { | ||
| "prod": {"aws": "prod-aws-value"}, | ||
| "dev": {"aws": "dev-aws-value"}, | ||
| } | ||
| }, | ||
| "Resources": { | ||
| "Topic1": { | ||
| "Type": "AWS::SNS::Topic", | ||
| "Properties": { | ||
| "TopicName": name1, | ||
| "DisplayName": { | ||
| "Fn::FindInMap": [ | ||
| "ComplexMap", | ||
| {"Ref": "Environment"}, | ||
| {"Ref": "AWS::Partition"}, | ||
| ] | ||
| }, | ||
| }, | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| capture_update_process(snapshot, template_1, template_2) |
There was a problem hiding this comment.
comment: capture_update_process supports passing parameters, you could simply pass the environment as a parameter and save 30 lines of code. Unless you're really interested on testing the default parameter.
52fba9e to
3aefe4c
Compare
Motivation
When redeploying CloudFormation stacks that contain
Fn::FindInMapwith nested intrinsic functions (like{"Ref": "AWS::Partition"}), LocalStack raised a misleading error:This particularly affected CDK-generated templates that use CloudFront distributions with Route53 ARecord alias targets, where the hosted zone ID is determined using:
{ "Fn::FindInMap": [ "AWSCloudFrontPartitionHostedZoneIdMap", {"Ref": "AWS::Partition"}, "zoneId" ] }Changes
Modified _resolve_intrinsic_function_fn_find_in_map in the changeset model to handle non-terminal values (nested intrinsic functions) by calling parent_change_type_of() instead of raising NotImplementedError.
Tests
Added 3 AWS-validated tests to test_change_set_mappings.py to validate the exact bug scenario and that change detection still works correctly.
Related
Fixes #13491
Closes UNC-165