github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/getRegion.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  // `getRegion` provides details about a specific AWS region.
    15  //
    16  // As well as validating a given region name this resource can be used to
    17  // discover the name of the region configured within the provider. The latter
    18  // can be useful in a child module which is inheriting an AWS provider
    19  // configuration from its parent module.
    20  //
    21  // ## Example Usage
    22  //
    23  // The following example shows how the resource might be used to obtain
    24  // the name of the AWS region configured on the provider.
    25  //
    26  // <!--Start PulumiCodeChooser -->
    27  // ```go
    28  // package main
    29  //
    30  // import (
    31  //
    32  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    33  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    34  //
    35  // )
    36  //
    37  //	func main() {
    38  //		pulumi.Run(func(ctx *pulumi.Context) error {
    39  //			_, err := aws.GetRegion(ctx, nil, nil)
    40  //			if err != nil {
    41  //				return err
    42  //			}
    43  //			return nil
    44  //		})
    45  //	}
    46  //
    47  // ```
    48  // <!--End PulumiCodeChooser -->
    49  func GetRegion(ctx *pulumi.Context, args *GetRegionArgs, opts ...pulumi.InvokeOption) (*GetRegionResult, error) {
    50  	opts = internal.PkgInvokeDefaultOpts(opts)
    51  	var rv GetRegionResult
    52  	err := ctx.Invoke("aws:index/getRegion:getRegion", args, &rv, opts...)
    53  	if err != nil {
    54  		return nil, err
    55  	}
    56  	return &rv, nil
    57  }
    58  
    59  // A collection of arguments for invoking getRegion.
    60  type GetRegionArgs struct {
    61  	// EC2 endpoint of the region to select.
    62  	Endpoint *string `pulumi:"endpoint"`
    63  	Id       *string `pulumi:"id"`
    64  	// Full name of the region to select.
    65  	Name *string `pulumi:"name"`
    66  }
    67  
    68  // A collection of values returned by getRegion.
    69  type GetRegionResult struct {
    70  	// Region's description in this format: "Location (Region name)".
    71  	Description string `pulumi:"description"`
    72  	// EC2 endpoint for the selected region.
    73  	Endpoint string `pulumi:"endpoint"`
    74  	Id       string `pulumi:"id"`
    75  	// Name of the selected region.
    76  	Name string `pulumi:"name"`
    77  }
    78  
    79  func GetRegionOutput(ctx *pulumi.Context, args GetRegionOutputArgs, opts ...pulumi.InvokeOption) GetRegionResultOutput {
    80  	return pulumi.ToOutputWithContext(context.Background(), args).
    81  		ApplyT(func(v interface{}) (GetRegionResult, error) {
    82  			args := v.(GetRegionArgs)
    83  			r, err := GetRegion(ctx, &args, opts...)
    84  			var s GetRegionResult
    85  			if r != nil {
    86  				s = *r
    87  			}
    88  			return s, err
    89  		}).(GetRegionResultOutput)
    90  }
    91  
    92  // A collection of arguments for invoking getRegion.
    93  type GetRegionOutputArgs struct {
    94  	// EC2 endpoint of the region to select.
    95  	Endpoint pulumi.StringPtrInput `pulumi:"endpoint"`
    96  	Id       pulumi.StringPtrInput `pulumi:"id"`
    97  	// Full name of the region to select.
    98  	Name pulumi.StringPtrInput `pulumi:"name"`
    99  }
   100  
   101  func (GetRegionOutputArgs) ElementType() reflect.Type {
   102  	return reflect.TypeOf((*GetRegionArgs)(nil)).Elem()
   103  }
   104  
   105  // A collection of values returned by getRegion.
   106  type GetRegionResultOutput struct{ *pulumi.OutputState }
   107  
   108  func (GetRegionResultOutput) ElementType() reflect.Type {
   109  	return reflect.TypeOf((*GetRegionResult)(nil)).Elem()
   110  }
   111  
   112  func (o GetRegionResultOutput) ToGetRegionResultOutput() GetRegionResultOutput {
   113  	return o
   114  }
   115  
   116  func (o GetRegionResultOutput) ToGetRegionResultOutputWithContext(ctx context.Context) GetRegionResultOutput {
   117  	return o
   118  }
   119  
   120  // Region's description in this format: "Location (Region name)".
   121  func (o GetRegionResultOutput) Description() pulumi.StringOutput {
   122  	return o.ApplyT(func(v GetRegionResult) string { return v.Description }).(pulumi.StringOutput)
   123  }
   124  
   125  // EC2 endpoint for the selected region.
   126  func (o GetRegionResultOutput) Endpoint() pulumi.StringOutput {
   127  	return o.ApplyT(func(v GetRegionResult) string { return v.Endpoint }).(pulumi.StringOutput)
   128  }
   129  
   130  func (o GetRegionResultOutput) Id() pulumi.StringOutput {
   131  	return o.ApplyT(func(v GetRegionResult) string { return v.Id }).(pulumi.StringOutput)
   132  }
   133  
   134  // Name of the selected region.
   135  func (o GetRegionResultOutput) Name() pulumi.StringOutput {
   136  	return o.ApplyT(func(v GetRegionResult) string { return v.Name }).(pulumi.StringOutput)
   137  }
   138  
   139  func init() {
   140  	pulumi.RegisterOutputType(GetRegionResultOutput{})
   141  }