!ForEach 💪https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-foreach.html
AWSTemplateFormatVersion: 2010-09-09Transform: 'AWS::LanguageExtensions'Resources: 'Fn::ForEach::Tables': - TableName - [Points, Score, Name, Leaderboard] - 'DynamoDB${TableName}': Type: 'AWS::DynamoDB::Table' Properties: TableName: !Ref TableName AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: id KeyType: HASH ProvisionedThroughput: ReadCapacityUnits: '5' WriteCapacityUnits: '5'Fn::ForEach can be used in the sections:▫️ Resource
▪️ Resource properties
▫️ Conditions
▫️ Outputs
Fn::ForEach parametersIdentifier (String) → Identifier is used to refer to the current element we’re iterating over within the Collection (Array of Strings).Collection (Array of Strings) → Array of values that the Identifier can take.OutputKey (String) → The key of the resulting key-value pair for the given element in the collection that will be merged to the parent object.OutputValue (Any) → The value of the resulting key-value pair for the given element in the collection that will be merged to the parent object.Note: the syntax of
Fn::ForEach declaration has a suffix where the UniqueLoopName is used to identify the loop. This allows multiple Fn::ForEach function references to be declared on a given level.#CloudFormation