2

I would like to present a list of availability zones for a parameters options in a CloudFormation template for the region in the console. Preferably using the Troposphere Python mod.

I see that I would be calling Fn::GetAZs to create a list of availableValues to use as options to the parameter but wondering if there is an example of this already or if it is possible.

So something like this:

template.add_parameter('AZs', AllowedValues= call Fn::GetAZs here some how ... )
Narayan
  • 91
  • 6

1 Answers1

4

I ended up picking the AZs with this instead of using a parameter for user to choose.

        AvailabilityZone=Select(0, GetAZs(Ref("AWS::Region"))), ... 

It is in the docs - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getavailabilityzones.html

Equivalent template object looks like this:

"mySubnet" : {
  "Type" : "AWS::EC2::Subnet",
  "Properties" : {
    "VpcId" : { 
      "Ref" : "VPC"   
    },
    "CidrBlock" : "10.0.0.0/24",
    "AvailabilityZone" : {
      "Fn::Select" : [ 
        "0", 
        { 
          "Fn::GetAZs" : "" 
        } 
      ]
    }
  }
}
Narayan
  • 91
  • 6