GetAvailabilityZones
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.getAvailabilityZone (singular) data source,
which provides some details about a specific availability zone.
When Local Zones are enabled in a region, by default the API and this data source include both Local Zones and Availability Zones. To return only Availability Zones, see the example section below.
Example Usage
By State
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var available = Output.Create(Aws.GetAvailabilityZones.InvokeAsync(new Aws.GetAvailabilityZonesArgs
{
State = "available",
}));
var primary = new Aws.Ec2.Subnet("primary", new Aws.Ec2.SubnetArgs
{
AvailabilityZone = available.Apply(available => available.Names[0]),
});
// ...
var secondary = new Aws.Ec2.Subnet("secondary", new Aws.Ec2.SubnetArgs
{
AvailabilityZone = available.Apply(available => available.Names[1]),
});
// ...
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
opt0 := "available"
available, err := aws.GetAvailabilityZones(ctx, &aws.GetAvailabilityZonesArgs{
State: &opt0,
}, nil)
if err != nil {
return err
}
_, err = ec2.NewSubnet(ctx, "primary", &ec2.SubnetArgs{
AvailabilityZone: pulumi.String(available.Names[0]),
})
if err != nil {
return err
}
_, err = ec2.NewSubnet(ctx, "secondary", &ec2.SubnetArgs{
AvailabilityZone: pulumi.String(available.Names[1]),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
available = aws.get_availability_zones(state="available")
primary = aws.ec2.Subnet("primary", availability_zone=available.names[0])
# ...
secondary = aws.ec2.Subnet("secondary", availability_zone=available.names[1])
# ...import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const available = aws.getAvailabilityZones({
state: "available",
});
const primary = new aws.ec2.Subnet("primary", {availabilityZone: available.then(available => available.names[0])});
// ...
const secondary = new aws.ec2.Subnet("secondary", {availabilityZone: available.then(available => available.names[1])});
// ...By Filter
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = Output.Create(Aws.GetAvailabilityZones.InvokeAsync(new Aws.GetAvailabilityZonesArgs
{
AllAvailabilityZones = true,
Filters =
{
new Aws.Inputs.GetAvailabilityZonesFilterArgs
{
Name = "opt-in-status",
Values =
{
"not-opted-in",
"opted-in",
},
},
},
}));
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
opt0 := true
_, err := aws.GetAvailabilityZones(ctx, &aws.GetAvailabilityZonesArgs{
AllAvailabilityZones: &opt0,
Filters: []aws.GetAvailabilityZonesFilter{
aws.GetAvailabilityZonesFilter{
Name: "opt-in-status",
Values: []string{
"not-opted-in",
"opted-in",
},
},
},
}, nil)
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
example = aws.get_availability_zones(all_availability_zones=True,
filters=[{
"name": "opt-in-status",
"values": [
"not-opted-in",
"opted-in",
],
}])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = pulumi.output(aws.getAvailabilityZones({
allAvailabilityZones: true,
filters: [{
name: "opt-in-status",
values: [
"not-opted-in",
"opted-in",
],
}],
}, { async: true }));Using GetAvailabilityZones
function getAvailabilityZones(args: GetAvailabilityZonesArgs, opts?: InvokeOptions): Promise<GetAvailabilityZonesResult>function get_availability_zones(all_availability_zones=None, blacklisted_names=None, blacklisted_zone_ids=None, exclude_names=None, exclude_zone_ids=None, filters=None, group_names=None, state=None, opts=None)func GetAvailabilityZones(ctx *Context, args *GetAvailabilityZonesArgs, opts ...InvokeOption) (*GetAvailabilityZonesResult, error)public static class GetAvailabilityZones {
public static Task<GetAvailabilityZonesResult> InvokeAsync(GetAvailabilityZonesArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- All
Availability boolZones Set to
trueto include all Availability Zones and Local Zones regardless of your opt in status.- Blacklisted
Names List<string> List of Availability Zone names to exclude. Use
exclude_namesinstead.- Blacklisted
Zone List<string>Ids List of Availability Zone IDs to exclude. Use
exclude_zone_idsinstead.- Exclude
Names List<string> List of Availability Zone names to exclude.
- Exclude
Zone List<string>Ids List of Availability Zone IDs to exclude.
- Filters
List<Get
Availability Zones Filter Args> Configuration block(s) for filtering. Detailed below.
- Group
Names List<string> - State string
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.
- All
Availability boolZones Set to
trueto include all Availability Zones and Local Zones regardless of your opt in status.- Blacklisted
Names []string List of Availability Zone names to exclude. Use
exclude_namesinstead.- Blacklisted
Zone []stringIds List of Availability Zone IDs to exclude. Use
exclude_zone_idsinstead.- Exclude
Names []string List of Availability Zone names to exclude.
- Exclude
Zone []stringIds List of Availability Zone IDs to exclude.
- Filters
[]Get
Availability Zones Filter Configuration block(s) for filtering. Detailed below.
- Group
Names []string - State string
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.
- all
Availability booleanZones Set to
trueto include all Availability Zones and Local Zones regardless of your opt in status.- blacklisted
Names string[] List of Availability Zone names to exclude. Use
exclude_namesinstead.- blacklisted
Zone string[]Ids List of Availability Zone IDs to exclude. Use
exclude_zone_idsinstead.- exclude
Names string[] List of Availability Zone names to exclude.
- exclude
Zone string[]Ids List of Availability Zone IDs to exclude.
- filters
Get
Availability Zones Filter[] Configuration block(s) for filtering. Detailed below.
- group
Names string[] - state string
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.
- all_
availability_ boolzones Set to
trueto include all Availability Zones and Local Zones regardless of your opt in status.- blacklisted_
names List[str] List of Availability Zone names to exclude. Use
exclude_namesinstead.- blacklisted_
zone_ List[str]ids List of Availability Zone IDs to exclude. Use
exclude_zone_idsinstead.- exclude_
names List[str] List of Availability Zone names to exclude.
- exclude_
zone_ List[str]ids List of Availability Zone IDs to exclude.
- filters
List[Get
Availability Zones Filter] Configuration block(s) for filtering. Detailed below.
- group_
names List[str] - state str
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.
GetAvailabilityZones Result
The following output properties are available:
- Id string
The provider-assigned unique ID for this managed resource.
- Names List<string>
A list of the Availability Zone names available to the account.
- Zone
Ids List<string> A list of the Availability Zone IDs available to the account.
- All
Availability boolZones - Blacklisted
Names List<string> - Blacklisted
Zone List<string>Ids - Exclude
Names List<string> - Exclude
Zone List<string>Ids - Filters
List<Get
Availability Zones Filter> - Group
Names List<string> - State string
- Id string
The provider-assigned unique ID for this managed resource.
- Names []string
A list of the Availability Zone names available to the account.
- Zone
Ids []string A list of the Availability Zone IDs available to the account.
- All
Availability boolZones - Blacklisted
Names []string - Blacklisted
Zone []stringIds - Exclude
Names []string - Exclude
Zone []stringIds - Filters
[]Get
Availability Zones Filter - Group
Names []string - State string
- id string
The provider-assigned unique ID for this managed resource.
- names string[]
A list of the Availability Zone names available to the account.
- zone
Ids string[] A list of the Availability Zone IDs available to the account.
- all
Availability booleanZones - blacklisted
Names string[] - blacklisted
Zone string[]Ids - exclude
Names string[] - exclude
Zone string[]Ids - filters
Get
Availability Zones Filter[] - group
Names string[] - state string
- id str
The provider-assigned unique ID for this managed resource.
- names List[str]
A list of the Availability Zone names available to the account.
- zone_
ids List[str] A list of the Availability Zone IDs available to the account.
- all_
availability_ boolzones - blacklisted_
names List[str] - blacklisted_
zone_ List[str]ids - exclude_
names List[str] - exclude_
zone_ List[str]ids - filters
List[Get
Availability Zones Filter] - group_
names List[str] - state str
Supporting Types
GetAvailabilityZonesFilter
- Name string
The name of the filter field. Valid values can be found in the EC2 DescribeAvailabilityZones API Reference.
- Values List<string>
Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
- Name string
The name of the filter field. Valid values can be found in the EC2 DescribeAvailabilityZones API Reference.
- Values []string
Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
- name string
The name of the filter field. Valid values can be found in the EC2 DescribeAvailabilityZones API Reference.
- values string[]
Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
- name str
The name of the filter field. Valid values can be found in the EC2 DescribeAvailabilityZones API Reference.
- values List[str]
Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.