Autoscaling across multiple subnets using AWS Clou

2019-07-09 01:34发布

问题:

I am unable to create a Cloudformation template to autoscale across 2 different public subnets. I keep getting the error

CREATE_FAILED
AWS::AutoScaling::AutoScalingGroup
The availability zones of the specified subnets and the Auto Scaling group do not match

I have extensively researched all the different template code possibilities and I've tried them all, including

Defining the exact AZs like this:

AvailabilityZones" : [ us-west-2a, us-west-2b ],

Using the VPCZone Identifier property instead and leaving the AvailabilityZone property out of the resource:

"VPCZoneIdentifier" : [ subnet-1234, subnet-5678 ]

but here is my latest attempt:

"ASASGS3JJ": {
        "Type": "AWS::AutoScaling::AutoScalingGroup",
        "Properties": {
            "AvailabilityZones": {
                "Fn::GetAZs": ""
            },
            "InstanceId": {
                "Ref": "EC2I12Q2R"
            },
            "LoadBalancerNames": [
                "ELBLB2IQL9"
            ],
            "MaxSize": 2,
            "MinSize": 2
        },

Unfortunately still getting the same error. Can I please get some assistance on how to properly format? Do I need to change any code outside of the Autoscaling group resource?

回答1:

You need to specify your region:

"AvailabilityZones":{ "Fn::GetAZs" : { "Ref" : "AWS::Region" } }



回答2:

I ended up using a LaunchConfiguration and removing AvailabilityZones parameter. That seems to have fixed it.