Finding AWS Account ID
AWS uses account ID in various places. This is a short reading helping you to identify the place to find your AWS account id and its application in various places. In my case, I was working on pushing a docker image onto AWS Elastic Container Registry (ECR) when I realized I need to locate AWS account id as part of cli.
Account ID on AWS Console
Log into AWS Console, click on My Account.
Account id can be found on the top of the page.
Find Account ID using cli
In order to use aws cli, you will need to install aws command line sdk first. You will need to set up your own aws credential file in ~/.aws/credentials . Click here to get to know more about aws cli sdk.
aws sts get-caller-identity
Find Account ID thru API call
In order to use aws cli, you will need to install aws command line sdk first. You will need to set up your own aws credential file in ~/.aws/credentials . I used Python boto3 library to access aws sts api.
import boto3aws_account_id = boto3.client('sts').get_caller_identity().get('Account')