opentofu/website/source/docs/providers/aws/d/availability_zones.html.markdown
Martin Atkins fca9216f53 provider/aws: availability zone data source
This adds a singular data source in addition to the existing plural one.
This allows retrieving data about a specific AZ.

As a helper for writing reusable modules, the AZ letter (without its
usual region name prefix) is exposed so that it can be used in
region-agnostic mappings where a different value is used per AZ, such as
for subnet numbering schemes.
2016-09-24 15:19:33 -07:00

1.5 KiB

layout page_title sidebar_current description
aws AWS: aws_availability_zones docs-aws-datasource-availability-zones Provides a list of Availability Zones which can be used by an AWS account.

aws_availability_zones

The Availability Zones data source allows access to the list of AWS Availability Zones which can be accessed by an AWS account within the region configured in the provider.

This is different from the aws_availability_zone (singular) data source, which provides some details about a specific availability zone.

Example Usage

# Declare the data source
data "aws_availability_zones" "available" {}

# e.g. Create subnets in the first two available availability zones

resource "aws_subnet" "primary" {
  availability_zone = "${data.aws_availability_zones.available.names[0]}"

  # Other properties...
}

resource "aws_subnet" "secondary" {
  availability_zone = "${data.aws_availability_zones.available.names[1]}"

  # Other properties...
}

Argument Reference

The following arguments are supported:

  • state - (Optional) Allows to filter list of Availability Zones based on their current state. Can be either "available", "information", "impaired" or "unavailable". By default the list includes a complete set of Availability Zones to which the underlying AWS account has access, regardless of their state.

Attributes Reference

The following attributes are exported:

  • names - A list of the Availability Zone names available to the account.