github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/getRegions.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  // Provides information about AWS Regions. Can be used to filter regions i.e., by Opt-In status or only regions enabled for current account. To get details like endpoint and description of each region the data source can be combined with the `getRegion` data source.
    15  //
    16  // ## Example Usage
    17  //
    18  // Enabled AWS Regions:
    19  //
    20  // <!--Start PulumiCodeChooser -->
    21  // ```go
    22  // package main
    23  //
    24  // import (
    25  //
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			_, err := aws.GetRegions(ctx, nil, nil)
    34  //			if err != nil {
    35  //				return err
    36  //			}
    37  //			return nil
    38  //		})
    39  //	}
    40  //
    41  // ```
    42  // <!--End PulumiCodeChooser -->
    43  //
    44  // # All the regions regardless of the availability
    45  //
    46  // <!--Start PulumiCodeChooser -->
    47  // ```go
    48  // package main
    49  //
    50  // import (
    51  //
    52  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    53  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    54  //
    55  // )
    56  //
    57  //	func main() {
    58  //		pulumi.Run(func(ctx *pulumi.Context) error {
    59  //			_, err := aws.GetRegions(ctx, &aws.GetRegionsArgs{
    60  //				AllRegions: pulumi.BoolRef(true),
    61  //			}, nil)
    62  //			if err != nil {
    63  //				return err
    64  //			}
    65  //			return nil
    66  //		})
    67  //	}
    68  //
    69  // ```
    70  // <!--End PulumiCodeChooser -->
    71  //
    72  // To see regions that are filtered by `"not-opted-in"`, the `allRegions` argument needs to be set to `true` or no results will be returned.
    73  //
    74  // <!--Start PulumiCodeChooser -->
    75  // ```go
    76  // package main
    77  //
    78  // import (
    79  //
    80  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    81  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    82  //
    83  // )
    84  //
    85  //	func main() {
    86  //		pulumi.Run(func(ctx *pulumi.Context) error {
    87  //			_, err := aws.GetRegions(ctx, &aws.GetRegionsArgs{
    88  //				AllRegions: pulumi.BoolRef(true),
    89  //				Filters: []aws.GetRegionsFilter{
    90  //					{
    91  //						Name: "opt-in-status",
    92  //						Values: []string{
    93  //							"not-opted-in",
    94  //						},
    95  //					},
    96  //				},
    97  //			}, nil)
    98  //			if err != nil {
    99  //				return err
   100  //			}
   101  //			return nil
   102  //		})
   103  //	}
   104  //
   105  // ```
   106  // <!--End PulumiCodeChooser -->
   107  func GetRegions(ctx *pulumi.Context, args *GetRegionsArgs, opts ...pulumi.InvokeOption) (*GetRegionsResult, error) {
   108  	opts = internal.PkgInvokeDefaultOpts(opts)
   109  	var rv GetRegionsResult
   110  	err := ctx.Invoke("aws:index/getRegions:getRegions", args, &rv, opts...)
   111  	if err != nil {
   112  		return nil, err
   113  	}
   114  	return &rv, nil
   115  }
   116  
   117  // A collection of arguments for invoking getRegions.
   118  type GetRegionsArgs struct {
   119  	// If true the source will query all regions regardless of availability.
   120  	AllRegions *bool `pulumi:"allRegions"`
   121  	// Configuration block(s) to use as filters. Detailed below.
   122  	Filters []GetRegionsFilter `pulumi:"filters"`
   123  	// Identifier of the current partition (e.g., `aws` in AWS Commercial, `aws-cn` in AWS China).
   124  	Id *string `pulumi:"id"`
   125  }
   126  
   127  // A collection of values returned by getRegions.
   128  type GetRegionsResult struct {
   129  	AllRegions *bool              `pulumi:"allRegions"`
   130  	Filters    []GetRegionsFilter `pulumi:"filters"`
   131  	// Identifier of the current partition (e.g., `aws` in AWS Commercial, `aws-cn` in AWS China).
   132  	Id string `pulumi:"id"`
   133  	// Names of regions that meets the criteria.
   134  	Names []string `pulumi:"names"`
   135  }
   136  
   137  func GetRegionsOutput(ctx *pulumi.Context, args GetRegionsOutputArgs, opts ...pulumi.InvokeOption) GetRegionsResultOutput {
   138  	return pulumi.ToOutputWithContext(context.Background(), args).
   139  		ApplyT(func(v interface{}) (GetRegionsResult, error) {
   140  			args := v.(GetRegionsArgs)
   141  			r, err := GetRegions(ctx, &args, opts...)
   142  			var s GetRegionsResult
   143  			if r != nil {
   144  				s = *r
   145  			}
   146  			return s, err
   147  		}).(GetRegionsResultOutput)
   148  }
   149  
   150  // A collection of arguments for invoking getRegions.
   151  type GetRegionsOutputArgs struct {
   152  	// If true the source will query all regions regardless of availability.
   153  	AllRegions pulumi.BoolPtrInput `pulumi:"allRegions"`
   154  	// Configuration block(s) to use as filters. Detailed below.
   155  	Filters GetRegionsFilterArrayInput `pulumi:"filters"`
   156  	// Identifier of the current partition (e.g., `aws` in AWS Commercial, `aws-cn` in AWS China).
   157  	Id pulumi.StringPtrInput `pulumi:"id"`
   158  }
   159  
   160  func (GetRegionsOutputArgs) ElementType() reflect.Type {
   161  	return reflect.TypeOf((*GetRegionsArgs)(nil)).Elem()
   162  }
   163  
   164  // A collection of values returned by getRegions.
   165  type GetRegionsResultOutput struct{ *pulumi.OutputState }
   166  
   167  func (GetRegionsResultOutput) ElementType() reflect.Type {
   168  	return reflect.TypeOf((*GetRegionsResult)(nil)).Elem()
   169  }
   170  
   171  func (o GetRegionsResultOutput) ToGetRegionsResultOutput() GetRegionsResultOutput {
   172  	return o
   173  }
   174  
   175  func (o GetRegionsResultOutput) ToGetRegionsResultOutputWithContext(ctx context.Context) GetRegionsResultOutput {
   176  	return o
   177  }
   178  
   179  func (o GetRegionsResultOutput) AllRegions() pulumi.BoolPtrOutput {
   180  	return o.ApplyT(func(v GetRegionsResult) *bool { return v.AllRegions }).(pulumi.BoolPtrOutput)
   181  }
   182  
   183  func (o GetRegionsResultOutput) Filters() GetRegionsFilterArrayOutput {
   184  	return o.ApplyT(func(v GetRegionsResult) []GetRegionsFilter { return v.Filters }).(GetRegionsFilterArrayOutput)
   185  }
   186  
   187  // Identifier of the current partition (e.g., `aws` in AWS Commercial, `aws-cn` in AWS China).
   188  func (o GetRegionsResultOutput) Id() pulumi.StringOutput {
   189  	return o.ApplyT(func(v GetRegionsResult) string { return v.Id }).(pulumi.StringOutput)
   190  }
   191  
   192  // Names of regions that meets the criteria.
   193  func (o GetRegionsResultOutput) Names() pulumi.StringArrayOutput {
   194  	return o.ApplyT(func(v GetRegionsResult) []string { return v.Names }).(pulumi.StringArrayOutput)
   195  }
   196  
   197  func init() {
   198  	pulumi.RegisterOutputType(GetRegionsResultOutput{})
   199  }