Description
Community feedback from the Language Extensions blog post:
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):
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
Description
Community feedback from the Language Extensions blog post:
Fn::ForEachcurrently 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):
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