Verifies that boto3 is installed and AWS credentials are correctly configured by calling the AWS STS GetCallerIdentity API.
- Connects to AWS using the credentials configured on the machine
- Retrieves and prints the Account ID, User ARN, User ID, and active region
- Logs errors if credentials are missing or the request fails
- Python 3.x
boto3installed (pip install boto3)- AWS credentials configured via one of:
~/.aws/credentials- Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) - IAM role (if running on EC2 or Lambda)
From the repository root:
python -m stage_2.boto3_setup.boto3_setup_checkThe script uses the default boto3 credential chain and the session's configured Region. Set AWS_PROFILE and AWS_DEFAULT_REGION when you need to select a named profile and Region explicitly:
AWS_PROFILE=lab AWS_DEFAULT_REGION=us-east-1 python -m stage_2.boto3_setup.boto3_setup_checkAccount: 123456789012
User ARN: arn:aws:iam::123456789012:user/paulo-dev
User ID: AIDARABGFVH6AGEWB5UGL
Region: us-east-1
| Exception | Cause | Action |
|---|---|---|
NoCredentialsError |
No credentials found | Logs error, returns None |
ClientError |
AWS rejected the request | Logs error with details, returns None |
GetCallerIdentity is read-only and this project creates no AWS resources, so no cleanup is required. The output includes an account ID and ARN; avoid publishing real output in screenshots or logs. Prefer short-lived credentials, SSO, or an IAM role over long-lived access keys, and never commit credential files.