getCallerIdentity function
Future<GetCallerIdentityResult>
getCallerIdentity(
- GetCallerIdentityArgs args, {
- InvokeOptions? options,
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)
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 main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
current, err := aws.GetCallerIdentity(ctx, &aws.GetCallerIdentityArgs{}, nil)
if err != nil {
return err
}
ctx.Export("accountId", current.AccountId)
ctx.Export("callerArn", current.Arn)
ctx.Export("callerUser", current.UserId)
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_getcalleridentity" "current" {
}
output "accountId" {
value = data.aws_getcalleridentity.current.account_id
}
output "callerArn" {
value = data.aws_getcalleridentity.current.arn
}
output "callerUser" {
value = data.aws_getcalleridentity.current.user_id
}
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.ArrayList;
import java.util.Arrays;
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(GetCallerIdentityArgs.builder()
.build());
ctx.export("accountId", current.accountId());
ctx.export("callerArn", current.arn());
ctx.export("callerUser", current.userId());
}
}
variables:
current:
fn::invoke:
function: aws:getCallerIdentity
arguments: {}
outputs:
accountId: ${current.accountId}
callerArn: ${current.arn}
callerUser: ${current.userId}
args Arguments passed to this invoke. Arguments for getCallerIdentity.
options Invoke options controlling this call.
Implementation
Future<GetCallerIdentityResult> getCallerIdentity(
GetCallerIdentityArgs args, {
pulumi.InvokeOptions? options,
}) async {
final deployment = pulumi.Deployment.instance;
final result = await deployment.invoke<Map<String, dynamic>>(
'aws:index/getCallerIdentity:getCallerIdentity',
args.toMap(),
options: pulumi.toDeploymentInvokeOptions(options),
);
return GetCallerIdentityResult.fromMap(result);
}