Find your AWS Account ID in 2 simple ways


In this article, you’ll learn how you can find your AWS account ID quickly using two simple methods. One way is to get the account id via the AWS Console. The other way is to get it via the AWS CLI.

Your AWS account ID is a unique 12-digit identification number that is assigned to your AWS account. This number is important for you to track your account information with AWS.

To find your AWS account id with the AWS CLI, run the command sts get-caller-identity and it will return the 12-digit identification number of your AWS account. To find your AWS account id in the AWS Console, click on your role name in the top right corner to view the account ID.

Here are the detailed steps to find your AWS account ID in the AWS Console and AWS CLI.

Find your AWS Account ID with the AWS CLI

Before you can get your AWS account ID using the AWS CLI, make sure to log in to the specified AWS CLI profile. Otherwise, you can’t run any AWS CLI commands on your AWS account.

To get your AWS account id with the AWS CLI you run the following command:

aws sts get-caller-identity --query "Account" --output text

This will return your 12-digit identification number in plain text.

~ on  tst-account-sso (eu-central-1) [59m25s]
➜ aws sts get-caller-identity --query "Account" --output text

123456789012

Find your AWS Account ID in the AWS Console

To get your AWS account ID via the AWS Console, follow these 3 steps:

  1. Sign in to the AWS Console with your credentials.
  2. Click on your IAM user/role on the top right corner of the AWS Console
  3. You’ll see a dropdown menu containing the AWS Account ID
Get the AWS account id from the AWS Console
Get the AWS account id from the AWS Console

Conclusion

There are two methods available that allow you to find your AWS Account ID in a quick way. Via the AWS CLI, you can run the aws sts get-caller-identity command to immediately get the AWS Account ID. But if you’d rather use the AWS Console you can easily find the AWS Account ID in the top right corner of the navigation header.


Danny Steenman

Is a Principal Cloud Consultant with a background in DevOps Engineering and thorough hands-on experience in architecting and building highly scalable distributed systems on AWS Cloud using Infrastructure as Code.

A prominent leader who is passionate about sharing AWS technical expertise by writing technical articles.