github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/getCallerIdentity.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  // Use this data source to get the access to the effective Account ID, User ID, and ARN in
    15  // which this provider is authorized.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			current, err := aws.GetCallerIdentity(ctx, nil, nil)
    33  //			if err != nil {
    34  //				return err
    35  //			}
    36  //			ctx.Export("accountId", current.AccountId)
    37  //			ctx.Export("callerArn", current.Arn)
    38  //			ctx.Export("callerUser", current.UserId)
    39  //			return nil
    40  //		})
    41  //	}
    42  //
    43  // ```
    44  // <!--End PulumiCodeChooser -->
    45  func GetCallerIdentity(ctx *pulumi.Context, args *GetCallerIdentityArgs, opts ...pulumi.InvokeOption) (*GetCallerIdentityResult, error) {
    46  	opts = internal.PkgInvokeDefaultOpts(opts)
    47  	var rv GetCallerIdentityResult
    48  	err := ctx.Invoke("aws:index/getCallerIdentity:getCallerIdentity", args, &rv, opts...)
    49  	if err != nil {
    50  		return nil, err
    51  	}
    52  	return &rv, nil
    53  }
    54  
    55  // A collection of arguments for invoking getCallerIdentity.
    56  type GetCallerIdentityArgs struct {
    57  	// Account ID number of the account that owns or contains the calling entity.
    58  	Id *string `pulumi:"id"`
    59  }
    60  
    61  // A collection of values returned by getCallerIdentity.
    62  type GetCallerIdentityResult struct {
    63  	// AWS Account ID number of the account that owns or contains the calling entity.
    64  	AccountId string `pulumi:"accountId"`
    65  	// ARN associated with the calling entity.
    66  	Arn string `pulumi:"arn"`
    67  	// Account ID number of the account that owns or contains the calling entity.
    68  	Id string `pulumi:"id"`
    69  	// Unique identifier of the calling entity.
    70  	UserId string `pulumi:"userId"`
    71  }
    72  
    73  func GetCallerIdentityOutput(ctx *pulumi.Context, args GetCallerIdentityOutputArgs, opts ...pulumi.InvokeOption) GetCallerIdentityResultOutput {
    74  	return pulumi.ToOutputWithContext(context.Background(), args).
    75  		ApplyT(func(v interface{}) (GetCallerIdentityResult, error) {
    76  			args := v.(GetCallerIdentityArgs)
    77  			r, err := GetCallerIdentity(ctx, &args, opts...)
    78  			var s GetCallerIdentityResult
    79  			if r != nil {
    80  				s = *r
    81  			}
    82  			return s, err
    83  		}).(GetCallerIdentityResultOutput)
    84  }
    85  
    86  // A collection of arguments for invoking getCallerIdentity.
    87  type GetCallerIdentityOutputArgs struct {
    88  	// Account ID number of the account that owns or contains the calling entity.
    89  	Id pulumi.StringPtrInput `pulumi:"id"`
    90  }
    91  
    92  func (GetCallerIdentityOutputArgs) ElementType() reflect.Type {
    93  	return reflect.TypeOf((*GetCallerIdentityArgs)(nil)).Elem()
    94  }
    95  
    96  // A collection of values returned by getCallerIdentity.
    97  type GetCallerIdentityResultOutput struct{ *pulumi.OutputState }
    98  
    99  func (GetCallerIdentityResultOutput) ElementType() reflect.Type {
   100  	return reflect.TypeOf((*GetCallerIdentityResult)(nil)).Elem()
   101  }
   102  
   103  func (o GetCallerIdentityResultOutput) ToGetCallerIdentityResultOutput() GetCallerIdentityResultOutput {
   104  	return o
   105  }
   106  
   107  func (o GetCallerIdentityResultOutput) ToGetCallerIdentityResultOutputWithContext(ctx context.Context) GetCallerIdentityResultOutput {
   108  	return o
   109  }
   110  
   111  // AWS Account ID number of the account that owns or contains the calling entity.
   112  func (o GetCallerIdentityResultOutput) AccountId() pulumi.StringOutput {
   113  	return o.ApplyT(func(v GetCallerIdentityResult) string { return v.AccountId }).(pulumi.StringOutput)
   114  }
   115  
   116  // ARN associated with the calling entity.
   117  func (o GetCallerIdentityResultOutput) Arn() pulumi.StringOutput {
   118  	return o.ApplyT(func(v GetCallerIdentityResult) string { return v.Arn }).(pulumi.StringOutput)
   119  }
   120  
   121  // Account ID number of the account that owns or contains the calling entity.
   122  func (o GetCallerIdentityResultOutput) Id() pulumi.StringOutput {
   123  	return o.ApplyT(func(v GetCallerIdentityResult) string { return v.Id }).(pulumi.StringOutput)
   124  }
   125  
   126  // Unique identifier of the calling entity.
   127  func (o GetCallerIdentityResultOutput) UserId() pulumi.StringOutput {
   128  	return o.ApplyT(func(v GetCallerIdentityResult) string { return v.UserId }).(pulumi.StringOutput)
   129  }
   130  
   131  func init() {
   132  	pulumi.RegisterOutputType(GetCallerIdentityResultOutput{})
   133  }