How can I get the AWS Account ID
using awscli
?
I look for something like
$ aws <service> <options>
123456789012
Close, but not what I'm looking for: $ aws iam get-user
.
Finding Your Account ID using the AWS CLI Use the following command to view your user ID, account ID, and your user ARN: aws sts get-caller-identity.
AWS account IDs are not considered sensitive and you need not worry about sharing them via screenshot, code snippet, ill-considered tweet, or any other medium that you'd like.
In order to see which your default AWS CLI profile is, run the aws configure list command. The command shows the name of the default profile, the profile's security credentials and region. Copied! We can see that the default profile's name is tester in the example.
You can obtain the account number from within an EC2 instance by querying the instance metadata. The metadata is located in http://169.254.169.254/latest/dynamic/instance-identity/document.
The following command returns the account number:
aws sts get-caller-identity --query 'Account' --output text
Command details can be found here
(reformat the command as code session)
Need to get an AWS Account ID from the aws cli tool? Here you go:
aws sts get-caller-identity --output text --query 'Account'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With