github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/getAvailabilityZone.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package aws
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // `getAvailabilityZone` provides details about a specific availability zone (AZ)
    15  // in the current region.
    16  //
    17  // This can be used both to validate an availability zone given in a variable
    18  // and to split the AZ name into its component parts of an AWS region and an
    19  // AZ identifier letter. The latter may be useful e.g., for implementing a
    20  // consistent subnet numbering scheme across several regions by mapping both
    21  // the region and the subnet letter to network numbers.
    22  //
    23  // This is different from the `getAvailabilityZones` (plural) data source,
    24  // which provides a list of the available zones.
    25  //
    26  // ## Example Usage
    27  //
    28  // The following example shows how this data source might be used to derive
    29  // VPC and subnet CIDR prefixes systematically for an availability zone.
    30  //
    31  // <!--Start PulumiCodeChooser -->
    32  // ```go
    33  // package main
    34  //
    35  // import (
    36  //
    37  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    38  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    39  //	"github.com/pulumi/pulumi-std/sdk/go/std"
    40  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    41  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    42  //
    43  // )
    44  //
    45  //	func main() {
    46  //		pulumi.Run(func(ctx *pulumi.Context) error {
    47  //			cfg := config.New(ctx, "")
    48  //			regionNumber := map[string]interface{}{
    49  //				"ap-northeast-1": 5,
    50  //				"eu-central-1":   4,
    51  //				"us-east-1":      1,
    52  //				"us-west-1":      2,
    53  //				"us-west-2":      3,
    54  //			}
    55  //			if param := cfg.GetObject("regionNumber"); param != nil {
    56  //				regionNumber = param
    57  //			}
    58  //			azNumber := map[string]interface{}{
    59  //				"a": 1,
    60  //				"b": 2,
    61  //				"c": 3,
    62  //				"d": 4,
    63  //				"e": 5,
    64  //				"f": 6,
    65  //			}
    66  //			if param := cfg.GetObject("azNumber"); param != nil {
    67  //				azNumber = param
    68  //			}
    69  //			// Retrieve the AZ where we want to create network resources
    70  //			// This must be in the region selected on the AWS provider.
    71  //			example, err := aws.GetAvailabilityZone(ctx, &aws.GetAvailabilityZoneArgs{
    72  //				Name: pulumi.StringRef("eu-central-1a"),
    73  //			}, nil)
    74  //			if err != nil {
    75  //				return err
    76  //			}
    77  //			invokeCidrsubnet, err := std.Cidrsubnet(ctx, &std.CidrsubnetArgs{
    78  //				Input:   "10.0.0.0/8",
    79  //				Newbits: 4,
    80  //				Netnum:  regionNumber[example.Region],
    81  //			}, nil)
    82  //			if err != nil {
    83  //				return err
    84  //			}
    85  //			// Create a VPC for the region associated with the AZ
    86  //			exampleVpc, err := ec2.NewVpc(ctx, "example", &ec2.VpcArgs{
    87  //				CidrBlock: invokeCidrsubnet.Result,
    88  //			})
    89  //			if err != nil {
    90  //				return err
    91  //			}
    92  //			// Create a subnet for the AZ within the regional VPC
    93  //			_, err = ec2.NewSubnet(ctx, "example", &ec2.SubnetArgs{
    94  //				VpcId: exampleVpc.ID(),
    95  //				CidrBlock: exampleVpc.CidrBlock.ApplyT(func(cidrBlock string) (std.CidrsubnetResult, error) {
    96  //					return std.CidrsubnetOutput(ctx, std.CidrsubnetOutputArgs{
    97  //						Input:   cidrBlock,
    98  //						Newbits: 4,
    99  //						Netnum:  azNumber[example.NameSuffix],
   100  //					}, nil), nil
   101  //				}).(std.CidrsubnetResultOutput).ApplyT(func(invoke std.CidrsubnetResult) (*string, error) {
   102  //					return invoke.Result, nil
   103  //				}).(pulumi.StringPtrOutput),
   104  //			})
   105  //			if err != nil {
   106  //				return err
   107  //			}
   108  //			return nil
   109  //		})
   110  //	}
   111  //
   112  // ```
   113  // <!--End PulumiCodeChooser -->
   114  func GetAvailabilityZone(ctx *pulumi.Context, args *GetAvailabilityZoneArgs, opts ...pulumi.InvokeOption) (*GetAvailabilityZoneResult, error) {
   115  	opts = internal.PkgInvokeDefaultOpts(opts)
   116  	var rv GetAvailabilityZoneResult
   117  	err := ctx.Invoke("aws:index/getAvailabilityZone:getAvailabilityZone", args, &rv, opts...)
   118  	if err != nil {
   119  		return nil, err
   120  	}
   121  	return &rv, nil
   122  }
   123  
   124  // A collection of arguments for invoking getAvailabilityZone.
   125  type GetAvailabilityZoneArgs struct {
   126  	// Set to `true` to include all Availability Zones and Local Zones regardless of your opt in status.
   127  	AllAvailabilityZones *bool `pulumi:"allAvailabilityZones"`
   128  	// Configuration block(s) for filtering. Detailed below.
   129  	Filters []GetAvailabilityZoneFilter `pulumi:"filters"`
   130  	// Full name of the availability zone to select.
   131  	Name *string `pulumi:"name"`
   132  	// Specific availability zone state to require. May be any of `"available"`, `"information"` or `"impaired"`.
   133  	State *string `pulumi:"state"`
   134  	// Zone ID of the availability zone to select.
   135  	ZoneId *string `pulumi:"zoneId"`
   136  }
   137  
   138  // A collection of values returned by getAvailabilityZone.
   139  type GetAvailabilityZoneResult struct {
   140  	AllAvailabilityZones *bool                       `pulumi:"allAvailabilityZones"`
   141  	Filters              []GetAvailabilityZoneFilter `pulumi:"filters"`
   142  	// For Availability Zones, this is the same value as the Region name. For Local Zones, the name of the associated group, for example `us-west-2-lax-1`.
   143  	GroupName string `pulumi:"groupName"`
   144  	// The provider-assigned unique ID for this managed resource.
   145  	Id   string `pulumi:"id"`
   146  	Name string `pulumi:"name"`
   147  	// Part of the AZ name that appears after the region name, uniquely identifying the AZ within its region.
   148  	// For Availability Zones this is usually a single letter, for example `a` for the `us-west-2a` zone.
   149  	// For Local and Wavelength Zones this is a longer string, for example `wl1-sfo-wlz-1` for the `us-west-2-wl1-sfo-wlz-1` zone.
   150  	NameSuffix string `pulumi:"nameSuffix"`
   151  	// The name of the location from which the address is advertised.
   152  	NetworkBorderGroup string `pulumi:"networkBorderGroup"`
   153  	// For Availability Zones, this always has the value of `opt-in-not-required`. For Local Zones, this is the opt in status. The possible values are `opted-in` and `not-opted-in`.
   154  	OptInStatus string `pulumi:"optInStatus"`
   155  	// ID of the zone that handles some of the Local Zone or Wavelength Zone control plane operations, such as API calls.
   156  	ParentZoneId string `pulumi:"parentZoneId"`
   157  	// Name of the zone that handles some of the Local Zone or Wavelength Zone control plane operations, such as API calls.
   158  	ParentZoneName string `pulumi:"parentZoneName"`
   159  	// Region where the selected availability zone resides. This is always the region selected on the provider, since this data source searches only within that region.
   160  	Region string `pulumi:"region"`
   161  	State  string `pulumi:"state"`
   162  	ZoneId string `pulumi:"zoneId"`
   163  	// Type of zone. Values are `availability-zone`, `local-zone`, and `wavelength-zone`.
   164  	ZoneType string `pulumi:"zoneType"`
   165  }
   166  
   167  func GetAvailabilityZoneOutput(ctx *pulumi.Context, args GetAvailabilityZoneOutputArgs, opts ...pulumi.InvokeOption) GetAvailabilityZoneResultOutput {
   168  	return pulumi.ToOutputWithContext(context.Background(), args).
   169  		ApplyT(func(v interface{}) (GetAvailabilityZoneResult, error) {
   170  			args := v.(GetAvailabilityZoneArgs)
   171  			r, err := GetAvailabilityZone(ctx, &args, opts...)
   172  			var s GetAvailabilityZoneResult
   173  			if r != nil {
   174  				s = *r
   175  			}
   176  			return s, err
   177  		}).(GetAvailabilityZoneResultOutput)
   178  }
   179  
   180  // A collection of arguments for invoking getAvailabilityZone.
   181  type GetAvailabilityZoneOutputArgs struct {
   182  	// Set to `true` to include all Availability Zones and Local Zones regardless of your opt in status.
   183  	AllAvailabilityZones pulumi.BoolPtrInput `pulumi:"allAvailabilityZones"`
   184  	// Configuration block(s) for filtering. Detailed below.
   185  	Filters GetAvailabilityZoneFilterArrayInput `pulumi:"filters"`
   186  	// Full name of the availability zone to select.
   187  	Name pulumi.StringPtrInput `pulumi:"name"`
   188  	// Specific availability zone state to require. May be any of `"available"`, `"information"` or `"impaired"`.
   189  	State pulumi.StringPtrInput `pulumi:"state"`
   190  	// Zone ID of the availability zone to select.
   191  	ZoneId pulumi.StringPtrInput `pulumi:"zoneId"`
   192  }
   193  
   194  func (GetAvailabilityZoneOutputArgs) ElementType() reflect.Type {
   195  	return reflect.TypeOf((*GetAvailabilityZoneArgs)(nil)).Elem()
   196  }
   197  
   198  // A collection of values returned by getAvailabilityZone.
   199  type GetAvailabilityZoneResultOutput struct{ *pulumi.OutputState }
   200  
   201  func (GetAvailabilityZoneResultOutput) ElementType() reflect.Type {
   202  	return reflect.TypeOf((*GetAvailabilityZoneResult)(nil)).Elem()
   203  }
   204  
   205  func (o GetAvailabilityZoneResultOutput) ToGetAvailabilityZoneResultOutput() GetAvailabilityZoneResultOutput {
   206  	return o
   207  }
   208  
   209  func (o GetAvailabilityZoneResultOutput) ToGetAvailabilityZoneResultOutputWithContext(ctx context.Context) GetAvailabilityZoneResultOutput {
   210  	return o
   211  }
   212  
   213  func (o GetAvailabilityZoneResultOutput) AllAvailabilityZones() pulumi.BoolPtrOutput {
   214  	return o.ApplyT(func(v GetAvailabilityZoneResult) *bool { return v.AllAvailabilityZones }).(pulumi.BoolPtrOutput)
   215  }
   216  
   217  func (o GetAvailabilityZoneResultOutput) Filters() GetAvailabilityZoneFilterArrayOutput {
   218  	return o.ApplyT(func(v GetAvailabilityZoneResult) []GetAvailabilityZoneFilter { return v.Filters }).(GetAvailabilityZoneFilterArrayOutput)
   219  }
   220  
   221  // For Availability Zones, this is the same value as the Region name. For Local Zones, the name of the associated group, for example `us-west-2-lax-1`.
   222  func (o GetAvailabilityZoneResultOutput) GroupName() pulumi.StringOutput {
   223  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.GroupName }).(pulumi.StringOutput)
   224  }
   225  
   226  // The provider-assigned unique ID for this managed resource.
   227  func (o GetAvailabilityZoneResultOutput) Id() pulumi.StringOutput {
   228  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.Id }).(pulumi.StringOutput)
   229  }
   230  
   231  func (o GetAvailabilityZoneResultOutput) Name() pulumi.StringOutput {
   232  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.Name }).(pulumi.StringOutput)
   233  }
   234  
   235  // Part of the AZ name that appears after the region name, uniquely identifying the AZ within its region.
   236  // For Availability Zones this is usually a single letter, for example `a` for the `us-west-2a` zone.
   237  // For Local and Wavelength Zones this is a longer string, for example `wl1-sfo-wlz-1` for the `us-west-2-wl1-sfo-wlz-1` zone.
   238  func (o GetAvailabilityZoneResultOutput) NameSuffix() pulumi.StringOutput {
   239  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.NameSuffix }).(pulumi.StringOutput)
   240  }
   241  
   242  // The name of the location from which the address is advertised.
   243  func (o GetAvailabilityZoneResultOutput) NetworkBorderGroup() pulumi.StringOutput {
   244  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.NetworkBorderGroup }).(pulumi.StringOutput)
   245  }
   246  
   247  // For Availability Zones, this always has the value of `opt-in-not-required`. For Local Zones, this is the opt in status. The possible values are `opted-in` and `not-opted-in`.
   248  func (o GetAvailabilityZoneResultOutput) OptInStatus() pulumi.StringOutput {
   249  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.OptInStatus }).(pulumi.StringOutput)
   250  }
   251  
   252  // ID of the zone that handles some of the Local Zone or Wavelength Zone control plane operations, such as API calls.
   253  func (o GetAvailabilityZoneResultOutput) ParentZoneId() pulumi.StringOutput {
   254  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.ParentZoneId }).(pulumi.StringOutput)
   255  }
   256  
   257  // Name of the zone that handles some of the Local Zone or Wavelength Zone control plane operations, such as API calls.
   258  func (o GetAvailabilityZoneResultOutput) ParentZoneName() pulumi.StringOutput {
   259  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.ParentZoneName }).(pulumi.StringOutput)
   260  }
   261  
   262  // Region where the selected availability zone resides. This is always the region selected on the provider, since this data source searches only within that region.
   263  func (o GetAvailabilityZoneResultOutput) Region() pulumi.StringOutput {
   264  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.Region }).(pulumi.StringOutput)
   265  }
   266  
   267  func (o GetAvailabilityZoneResultOutput) State() pulumi.StringOutput {
   268  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.State }).(pulumi.StringOutput)
   269  }
   270  
   271  func (o GetAvailabilityZoneResultOutput) ZoneId() pulumi.StringOutput {
   272  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.ZoneId }).(pulumi.StringOutput)
   273  }
   274  
   275  // Type of zone. Values are `availability-zone`, `local-zone`, and `wavelength-zone`.
   276  func (o GetAvailabilityZoneResultOutput) ZoneType() pulumi.StringOutput {
   277  	return o.ApplyT(func(v GetAvailabilityZoneResult) string { return v.ZoneType }).(pulumi.StringOutput)
   278  }
   279  
   280  func init() {
   281  	pulumi.RegisterOutputType(GetAvailabilityZoneResultOutput{})
   282  }