1. Packages
  2. AWS Classic
  3. API Docs
  4. getCallerIdentity

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi

aws.getCallerIdentity

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi

    Use this data source to get the access to the effective Account ID, User ID, and ARN in which this provider is authorized.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const current = aws.getCallerIdentity({});
    export const accountId = current.then(current => current.accountId);
    export const callerArn = current.then(current => current.arn);
    export const callerUser = current.then(current => current.userId);
    
    import pulumi
    import pulumi_aws as aws
    
    current = aws.get_caller_identity()
    pulumi.export("accountId", current.account_id)
    pulumi.export("callerArn", current.arn)
    pulumi.export("callerUser", current.user_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		current, err := aws.GetCallerIdentity(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("accountId", current.AccountId)
    		ctx.Export("callerArn", current.Arn)
    		ctx.Export("callerUser", current.UserId)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var current = Aws.GetCallerIdentity.Invoke();
    
        return new Dictionary<string, object?>
        {
            ["accountId"] = current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId),
            ["callerArn"] = current.Apply(getCallerIdentityResult => getCallerIdentityResult.Arn),
            ["callerUser"] = current.Apply(getCallerIdentityResult => getCallerIdentityResult.UserId),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.AwsFunctions;
    import com.pulumi.aws.inputs.GetCallerIdentityArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var current = AwsFunctions.getCallerIdentity();
    
            ctx.export("accountId", current.applyValue(getCallerIdentityResult -> getCallerIdentityResult.accountId()));
            ctx.export("callerArn", current.applyValue(getCallerIdentityResult -> getCallerIdentityResult.arn()));
            ctx.export("callerUser", current.applyValue(getCallerIdentityResult -> getCallerIdentityResult.userId()));
        }
    }
    
    variables:
      current:
        fn::invoke:
          Function: aws:getCallerIdentity
          Arguments: {}
    outputs:
      accountId: ${current.accountId}
      callerArn: ${current.arn}
      callerUser: ${current.userId}
    

    Using getCallerIdentity

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getCallerIdentity(args: GetCallerIdentityArgs, opts?: InvokeOptions): Promise<GetCallerIdentityResult>
    function getCallerIdentityOutput(args: GetCallerIdentityOutputArgs, opts?: InvokeOptions): Output<GetCallerIdentityResult>
    def get_caller_identity(id: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetCallerIdentityResult
    def get_caller_identity_output(id: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetCallerIdentityResult]
    func GetCallerIdentity(ctx *Context, args *GetCallerIdentityArgs, opts ...InvokeOption) (*GetCallerIdentityResult, error)
    func GetCallerIdentityOutput(ctx *Context, args *GetCallerIdentityOutputArgs, opts ...InvokeOption) GetCallerIdentityResultOutput

    > Note: This function is named GetCallerIdentity in the Go SDK.

    public static class GetCallerIdentity 
    {
        public static Task<GetCallerIdentityResult> InvokeAsync(GetCallerIdentityArgs args, InvokeOptions? opts = null)
        public static Output<GetCallerIdentityResult> Invoke(GetCallerIdentityInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetCallerIdentityResult> getCallerIdentity(GetCallerIdentityArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:index/getCallerIdentity:getCallerIdentity
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Id string
    Account ID number of the account that owns or contains the calling entity.
    Id string
    Account ID number of the account that owns or contains the calling entity.
    id String
    Account ID number of the account that owns or contains the calling entity.
    id string
    Account ID number of the account that owns or contains the calling entity.
    id str
    Account ID number of the account that owns or contains the calling entity.
    id String
    Account ID number of the account that owns or contains the calling entity.

    getCallerIdentity Result

    The following output properties are available:

    AccountId string
    AWS Account ID number of the account that owns or contains the calling entity.
    Arn string
    ARN associated with the calling entity.
    Id string
    Account ID number of the account that owns or contains the calling entity.
    UserId string
    Unique identifier of the calling entity.
    AccountId string
    AWS Account ID number of the account that owns or contains the calling entity.
    Arn string
    ARN associated with the calling entity.
    Id string
    Account ID number of the account that owns or contains the calling entity.
    UserId string
    Unique identifier of the calling entity.
    accountId String
    AWS Account ID number of the account that owns or contains the calling entity.
    arn String
    ARN associated with the calling entity.
    id String
    Account ID number of the account that owns or contains the calling entity.
    userId String
    Unique identifier of the calling entity.
    accountId string
    AWS Account ID number of the account that owns or contains the calling entity.
    arn string
    ARN associated with the calling entity.
    id string
    Account ID number of the account that owns or contains the calling entity.
    userId string
    Unique identifier of the calling entity.
    account_id str
    AWS Account ID number of the account that owns or contains the calling entity.
    arn str
    ARN associated with the calling entity.
    id str
    Account ID number of the account that owns or contains the calling entity.
    user_id str
    Unique identifier of the calling entity.
    accountId String
    AWS Account ID number of the account that owns or contains the calling entity.
    arn String
    ARN associated with the calling entity.
    id String
    Account ID number of the account that owns or contains the calling entity.
    userId String
    Unique identifier of the calling entity.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi