Search code examples
aws-cloudformationtroposphere

Pre-populated list of availability zone options as parameter for cloudformation template


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 ... )

Solution

  • CloudFormation will provide a dropdown, i.e., a pre-populated list of availability zone options, for a parameter if its type is an Availability Zone. Basically, AWS will automatically provide the list; no extra work is needed.

    JSON

    "Parameters" : {
      "AvailabilityZone1" : {
        "Description" : "Availability Zone 1",
        "Type" : "AWS::EC2::AvailabilityZone::Name"
      }
    }
    

    YAML

    Parameters:
      AvailabilityZone1:
        Description: Availability Zone 1
        Type: AWS::EC2::AvailabilityZone::Name