How to create multiple AWS CloudFormation resources such as ec2 without AutoScaling group?

Some of the similar questions such as …

  • How to do conditioning in AWS CloudFormation?
  • How to do looking in AWS CloudFormation?

No it is not possible looping in AWS CloudFormation, there is no iteration you can specify in a template. You can, however, create an instance resource for each instance type. It’s a matter of copy and paste. To make it easy to tell CloudFormation which instances to run on stack creation, you can specify functions and conditions in a template. For example, you could create a parameter or parameters that indicate which instance types to start, and use conditions to start only the ones you specify.

Condition Functions in AWS CloudFormation
You can use intrinsic functions, such as Fn::If, Fn::Equals, and Fn::Not, to conditionally create stack resources. These conditions are evaluated based on input parameters that you declare when you create or update a stack. After you define all your conditions, you can associate them with resources or resource properties in the Resources and Outputs sections of a template.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html

Conditions in AWS CloudFormation
The optional Conditions section contains statements that define the circumstances under which entities are created or configured. For example, you can create a condition and then associate it with a resource or output so that AWS CloudFormation only creates the resource or output if the condition is true. Similarly, you can associate the condition with a property so that AWS CloudFormation only sets the property to a specific value if the condition is true. If the condition is false, AWS CloudFormation sets the property to a different value that you specify.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html

Rajesh Kumar
Follow me