Skip to content

Conversation

dcabib
Copy link

@dcabib dcabib commented Oct 6, 2025

Fixes the 2.5-year-old bug where SAM CLI crashed with AttributeError when processing templates using CloudFormation's Fn::ForEach.

Following AWS CLI's approach (aws/aws-cli#8096), we now detect and skip Fn::ForEach constructs during local parsing, letting CloudFormation expand them server-side.

Changes:

  • Added Fn::ForEach to unresolvable intrinsics
  • Updated resource metadata normalizer to skip ForEach blocks
  • Added informative logging
  • Updated providers to handle ForEach gracefully
  • Added integration tests

Testing:

  • All 5,870 unit tests pass
  • 94.12% code coverage
  • Verified with real templates

Closes #5647

Which issue(s) does this change fix?

Why is this change necessary?

How does it address the issue?

What side effects does this change have?

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Add input/output type hints to new functions/methods
  • Write design document if needed (Do I need to write a design document?)
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dcabib dcabib requested a review from a team as a code owner October 6, 2025 20:34
@github-actions github-actions bot added pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Oct 6, 2025
Fixes the 2.5-year-old bug where SAM CLI crashed with AttributeError when processing templates using CloudFormation's Fn::ForEach.

Following AWS CLI's approach (aws/aws-cli#8096), we now detect and skip Fn::ForEach constructs during local parsing, letting CloudFormation expand them server-side.

Changes:
- Added Fn::ForEach to unresolvable intrinsics
- Updated resource metadata normalizer to skip ForEach blocks
- Added informative logging
- Updated providers to handle ForEach gracefully
- Added integration tests

Testing:
- All 5,870 unit tests pass
- 94.12% code coverage
- Verified with real templates

Closes aws#5647
@dcabib dcabib force-pushed the fix/issue-5647-foreach-support branch from 678b731 to 9aa1bf7 Compare October 6, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Support LanguageExtensions feature Fn::ForEach

1 participant