Feature request: Fn::ForEach support for generating array items (not just resources)
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
## Description
Community feedback from the [Language Extensions blog post](https://builder.aws.com/content/3DiJq5vQ2hnGq1ddBlCApT8uy6u/dynamic-looping-comes-to-aws-sam):
`Fn::ForEach` currently generates top-level resources, conditions, and outputs. However, developers also need to generate **array items within a resource property** from a collection.
## Use Case
DynamoDB tables have several array-typed properties (e.g., `AttributeDefinitions`, `GlobalSecondaryIndexes`, `ReplicaUpdates`) where each item follows the same structure but varies by a key value. Currently, these must be manually listed even when a parameter provides the collection.
Example (desired behavior):
```yaml
Parameters:
Attributes:
Type: CommaDelimitedList
Default: "id,name,email"
Resources:
MyTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
Fn::ForEach::Attrs:
- AttrName
- !Ref Attributes
- AttributeName: !Sub ${AttrName}
AttributeType: S
```
## Current Workaround
Users maintain custom CloudFormation macros: https://github.com/mlhpdx/cloudformation-macros
## Source
Comment by Lee Harding on AWS Builder Center blog post, May 2026.
## Related
- #8637 (Language Extensions support PR)
- #5647 (original Fn::ForEach request)
Contributor guide
Assessment
This issue has not been assessed yet.