Is there a way in the json template under AWS::EC2::Instance to specify the number of instances?

有帮助吗?

解决方案

you can use auto scaling group with fixed size:

"MyFixedSizeGroup":{
        "Type":"AWS::AutoScaling::AutoScalingGroup",
        "Properties":{
            "LaunchConfigurationName":{"Ref":"GlobalWorkersSmallLaunchConf"},
            "AvailabilityZones" : [ "us-east-1a" ],
            "MinSize":"4",
            "MaxSize":"4",
            "DesiredCapacity":"4",
            "Tags":[{"Key":"Name", "Value":"worker instance", "PropagateAtLaunch":"true"}]          
        }           
}

and the desired launch configuration, for example:

"GlobalWorkersSmallLaunchConf":{
        "Type":"AWS::AutoScaling::LaunchConfiguration",
        "Properties":{"KeyName":{"Ref":"MyKeyName"},
                      "ImageId":"ami-SomeAmi",
                      "UserData":{"Fn::Base64":{"Fn::Join":["",[{"Ref":"SomeInitScript"}]]}},
                      "SecurityGroups":[{"Ref":"InstanceSecurityGroup"}],
                      "InstanceType":"m1.small",
                      "InstanceMonitoring":"false"
        }           
}

BTW- this wasn't available through the dashboard until last week.

其他提示

CloudFormation does not provide any feature which you cannot do from AWS Console. Can you provide number of instance to be created when you are creating it from the AWS Console? No, you cannot.

There is an option in AWS Console to specify number of instances to be created.

But, There is no such option Cloudforamtion for AWS::EC2::Instance.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top