X Tutup
Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

CloudFormation: Support nested intrinsic functions in Fn::FindInMap#13678

Merged
nik-localstack merged 1 commit intomainfrom
unc-165-resolve-cfn-notimplementederror
Feb 3, 2026
Merged

CloudFormation: Support nested intrinsic functions in Fn::FindInMap#13678
nik-localstack merged 1 commit intomainfrom
unc-165-resolve-cfn-notimplementederror

Conversation

@nik-localstack
Copy link
Contributor

@nik-localstack nik-localstack commented Feb 2, 2026

Motivation

When redeploying CloudFormation stacks that contain Fn::FindInMap with nested intrinsic functions (like {"Ref": "AWS::Partition"}), LocalStack raised a misleading error:

InternalFailure: The API action 'CreateChangeSet' for service 'cloudformation' is either not available in your current license plan or has not yet been emulated by LocalStack.

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

@nik-localstack nik-localstack self-assigned this Feb 2, 2026
@nik-localstack nik-localstack added aws:cloudformation AWS CloudFormation semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Feb 2, 2026
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test Results - Preflight, Unit

23 088 tests  ±0   21 229 ✅ ±0   6m 2s ⏱️ -20s
     1 suites ±0    1 859 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 3aefe4c. ± Comparison against base commit 39ec7cf.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

LocalStack Community integration with Pro

  2 files    2 suites   30m 53s ⏱️
586 tests 473 ✅ 113 💤 0 ❌
588 runs  473 ✅ 115 💤 0 ❌

Results for commit 3aefe4c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 1s ⏱️ -2s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 3aefe4c. ± Comparison against base commit 39ec7cf.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test Results (amd64) - Integration, Bootstrap

  5 files    5 suites   43m 31s ⏱️
610 tests 498 ✅ 112 💤 0 ❌
616 runs  498 ✅ 118 💤 0 ❌

Results for commit 3aefe4c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test Results - Alternative Providers

585 tests   322 ✅  17m 43s ⏱️
  1 suites  263 💤
  1 files      0 ❌

Results for commit 3aefe4c.

♻️ This comment has been updated with latest results.

@nik-localstack nik-localstack marked this pull request as ready for review February 2, 2026 15:21
@nik-localstack nik-localstack added the aws:cloudformation:v2 Issues related to the V2 CloudFormation engine label Feb 2, 2026
@nik-localstack nik-localstack added this to the 4.14 milestone Feb 2, 2026
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.

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.

Comment on lines +471 to +501
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)
Copy link
Member

Choose a reason for hiding this comment

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

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.

@nik-localstack nik-localstack force-pushed the unc-165-resolve-cfn-notimplementederror branch from 52fba9e to 3aefe4c Compare February 3, 2026 09:13
@nik-localstack nik-localstack merged commit e5fc583 into main Feb 3, 2026
43 checks passed
@nik-localstack nik-localstack deleted the unc-165-resolve-cfn-notimplementederror branch February 3, 2026 10:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

aws:cloudformation:v2 Issues related to the V2 CloudFormation engine aws:cloudformation AWS CloudFormation docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes 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.

bug: Redeploying an ARecord with CDK does not work when the Hosted Zone is created in another stack and retrieved with SSM Parameters

2 participants

X Tutup