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:
- Sign in to the AWS Console with your credentials.
- Click on your IAM user/role on the top right corner of the AWS Console
- You’ll see a dropdown menu containing the AWS Account ID
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.