Skip to content

How best to access the account id? #1745

Answered by jasdel
kaihendry asked this question in Q&A
Discussion options

You must be logged in to vote

The aws.Config will not provide the Account ID for the credentials being used. the best way to get the Account ID for the credentials, is via STS's GetCallerIdentity operation.

result, err := client.GetCallerIdentity(ctx, sts.GetCallerIdentityInput{})

fmt.Println(result.Account)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by vudh1
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants