Cloudformation Template

0

I am trying to create a template for launching instance using Cloudformation. I have to launch multiple instances using Parameter. So how to apply loops in YAML or JSON format as they don't support looping

Jeet
asked 5 months ago155 views
1 Answer
1
Accepted Answer

As you said there is no way of doing this with JSON/YAML natively. Instead you need to use features of CloudFormation to do it. There is a Fn::ForEach function available that might be of use to you. Without knowing exactly what you want/need it is hard to know the best solution for you. Alternatively it might be better to create a Template that creates just a single instance using Parameters as you mentioned and then automate the looping of this Template into multiple Stacks using a level "outside" of CloudFormation, something like a Step Function or SSM Automation Document. Or a good "old fashioned" script in the language of your choosing.

It is really dependant on the requirements you have.

profile pictureAWS
danjhd
answered 5 months ago
profile picture
EXPERT
reviewed 5 months ago
profile picture
EXPERT
Kallu
reviewed 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions