UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

156 lines 5.95 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.getAvailabilityZoneOutput = exports.getAvailabilityZone = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * `aws.getAvailabilityZone` provides details about a specific availability zone (AZ) * in the current Region. * * This can be used both to validate an availability zone given in a variable * and to split the AZ name into its component parts of an AWS Region and an * AZ identifier letter. The latter may be useful e.g., for implementing a * consistent subnet numbering scheme across several regions by mapping both * the region and the subnet letter to network numbers. * * This is different from the `aws.getAvailabilityZones` (plural) data source, * which provides a list of the available zones. * * ## Example Usage * * The following example shows how this data source might be used to derive * VPC and subnet CIDR prefixes systematically for an availability zone. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as std from "@pulumi/std"; * * const config = new pulumi.Config(); * const regionNumber = config.getObject<any>("regionNumber") || { * "ap-northeast-1": 5, * "eu-central-1": 4, * "us-east-1": 1, * "us-west-1": 2, * "us-west-2": 3, * }; * const azNumber = config.getObject<any>("azNumber") || { * a: 1, * b: 2, * c: 3, * d: 4, * e: 5, * f: 6, * }; * // Retrieve the AZ where we want to create network resources * // This must be in the region selected on the AWS provider. * const example = aws.getAvailabilityZone({ * name: "eu-central-1a", * }); * // Create a VPC for the region associated with the AZ * const exampleVpc = new aws.ec2.Vpc("example", {cidrBlock: example.then(example => std.cidrsubnet({ * input: "10.0.0.0/8", * newbits: 4, * netnum: regionNumber[example.region], * })).then(invoke => invoke.result)}); * // Create a subnet for the AZ within the regional VPC * const exampleSubnet = new aws.ec2.Subnet("example", { * vpcId: exampleVpc.id, * cidrBlock: pulumi.all([exampleVpc.cidrBlock, example]).apply(([cidrBlock, example]) => std.cidrsubnetOutput({ * input: cidrBlock, * newbits: 4, * netnum: azNumber[example.nameSuffix], * })).apply(invoke => invoke.result), * }); * ``` */ function getAvailabilityZone(args, opts) { args = args || {}; opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); return pulumi.runtime.invoke("aws:index/getAvailabilityZone:getAvailabilityZone", { "allAvailabilityZones": args.allAvailabilityZones, "filters": args.filters, "name": args.name, "region": args.region, "state": args.state, "zoneId": args.zoneId, }, opts); } exports.getAvailabilityZone = getAvailabilityZone; /** * `aws.getAvailabilityZone` provides details about a specific availability zone (AZ) * in the current Region. * * This can be used both to validate an availability zone given in a variable * and to split the AZ name into its component parts of an AWS Region and an * AZ identifier letter. The latter may be useful e.g., for implementing a * consistent subnet numbering scheme across several regions by mapping both * the region and the subnet letter to network numbers. * * This is different from the `aws.getAvailabilityZones` (plural) data source, * which provides a list of the available zones. * * ## Example Usage * * The following example shows how this data source might be used to derive * VPC and subnet CIDR prefixes systematically for an availability zone. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as std from "@pulumi/std"; * * const config = new pulumi.Config(); * const regionNumber = config.getObject<any>("regionNumber") || { * "ap-northeast-1": 5, * "eu-central-1": 4, * "us-east-1": 1, * "us-west-1": 2, * "us-west-2": 3, * }; * const azNumber = config.getObject<any>("azNumber") || { * a: 1, * b: 2, * c: 3, * d: 4, * e: 5, * f: 6, * }; * // Retrieve the AZ where we want to create network resources * // This must be in the region selected on the AWS provider. * const example = aws.getAvailabilityZone({ * name: "eu-central-1a", * }); * // Create a VPC for the region associated with the AZ * const exampleVpc = new aws.ec2.Vpc("example", {cidrBlock: example.then(example => std.cidrsubnet({ * input: "10.0.0.0/8", * newbits: 4, * netnum: regionNumber[example.region], * })).then(invoke => invoke.result)}); * // Create a subnet for the AZ within the regional VPC * const exampleSubnet = new aws.ec2.Subnet("example", { * vpcId: exampleVpc.id, * cidrBlock: pulumi.all([exampleVpc.cidrBlock, example]).apply(([cidrBlock, example]) => std.cidrsubnetOutput({ * input: cidrBlock, * newbits: 4, * netnum: azNumber[example.nameSuffix], * })).apply(invoke => invoke.result), * }); * ``` */ function getAvailabilityZoneOutput(args, opts) { args = args || {}; opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); return pulumi.runtime.invokeOutput("aws:index/getAvailabilityZone:getAvailabilityZone", { "allAvailabilityZones": args.allAvailabilityZones, "filters": args.filters, "name": args.name, "region": args.region, "state": args.state, "zoneId": args.zoneId, }, opts); } exports.getAvailabilityZoneOutput = getAvailabilityZoneOutput; //# sourceMappingURL=getAvailabilityZone.js.map