GetAZs

The intrinsic function Fn::GetAZs returns an array that lists Availability Zones for a specified region in alphabetical order. Because customers have access to different Availability Zones, the intrinsic function Fn::GetAZs enables template authors to write templates that adapt to the calling user’s access. That way you don’t have to hard-code a full list of Availability Zones for a specified region.

The get_azs method is the CloudFormation Fn::GetAZs equivalent.

Example Snippet

resource("MySubnet", "AWS::EC2::Subnet",
  VpcId: ref("Vpc"),
  CidrBlock: "10.0.0.0/24",
  AvailabilityZone: select("0", get_azs(''))
)

Example Output

Resources:
  MySubnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 10.0.0.0/24
      AvailabilityZone:
        Fn::Select:
        - '0'
        - Fn::GetAZs: ''

Back to Intrinsic Functions List.