Skip to content

Feature request: Fn::ForEach support for generating array items (not just resources) #9044

@singledigit

Description

@singledigit

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions