Skip to content

Instantly share code, notes, and snippets.

@sudharsans
Created August 10, 2018 16:46
Show Gist options
  • Save sudharsans/0a9112e2afb337990388d78bef031454 to your computer and use it in GitHub Desktop.
Save sudharsans/0a9112e2afb337990388d78bef031454 to your computer and use it in GitHub Desktop.
Cfn
Parameters:
InstanceCount:
Description: Number of EC2 instances (must be between 1 and 3).
Type: Number
Default: 1
MinValue: 1
MaxValue: 3
ConstraintDescription: Must be a number between 1 and 3.
Description: launch EC2 instances.
InstanceType:
Description: Launch EC2 instances.
Type: String
Default: t2.micro
AllowedValues: [ t2.micro ]
Conditions:
Launch1: !Equals [1, 1]
Launch2: !Not [!Equals [1, !Ref InstanceCount]]
Launch3: !Or
- !Not [!Equals [1, !Ref InstanceCount]]
- !Not [!Equals [2, !Ref InstanceCount]]
Resources:
Instance1:
Condition: Launch1
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref InstanceType
AvailabilityZone: us-east-1a
ImageId: ami-a4c7edb2
Instance2:
Condition: Launch2
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref InstanceType
AvailabilityZone: us-east-1a
ImageId: ami-a4c7edb2
Instance3:
Condition: Launch3
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref InstanceType
AvailabilityZone: us-east-1a
ImageId: ami-a4c7edb2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment