Skip to content

Instantly share code, notes, and snippets.

@neilmcguigan
Last active April 19, 2024 02:19
Show Gist options
  • Save neilmcguigan/ede993d170ad3f51578bf2800276fbad to your computer and use it in GitHub Desktop.
Save neilmcguigan/ede993d170ad3f51578bf2800276fbad to your computer and use it in GitHub Desktop.
cloudformation foreach loops
# the key is to use &{foo} for resource identifiers, to strip out bad chars
Transform: AWS::LanguageExtensions
Parameters:
BucketNames:
Type: CommaDelimitedList
Resources:
# "for each bucketname in bucketnames..."
Fn::ForEach::Loop1: # the loop name doesn't matter, but must be unique in the template
- BucketName
- !Ref BucketNames
- "&{BucketName}": # the cloudformation logical resource id
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment