# AWS CLI, CloudShell and SDKs

> Drive AWS from the command line and from code, configure profiles and SSO login, and stop clicking through the console for repeatable work. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/cloud-engineer/aws-cli
Last updated: 2026-11-28

Drive AWS from the command line and from code, configure profiles and SSO login, and stop clicking through the console for repeatable work.

Beginner · about 4 hours · difficulty 2/5

Learn first: [Billing Safety: Budgets, Alerts and Cost Traps](https://www.internhack.in/roadmaps/tracks/cloud-engineer/billing-safety), [Linux Command Line for Cloud Servers](https://www.internhack.in/roadmaps/tracks/cloud-engineer/linux-cli)

The console is fine for exploring, but real cloud work is scripted. The AWS CLI and SDKs call the same APIs the console uses.

### Installing and configuring

- Install **AWS CLI v2** on your laptop, or use **CloudShell** in the console, which comes pre-authenticated and is free.
- With IAM Identity Center, run aws configure sso, then aws sso login --profile dev. Credentials are short-lived, which is much safer than long-term access keys.
- Use **named profiles** (--profile or the AWS_PROFILE variable) to switch between accounts.
- Always check who you are with aws sts get-caller-identity.

### Useful patterns

- --region to target Mumbai (ap-south-1) explicitly.
- --query (JMESPath) and --output table or json to shape results.
- Pagination is automatic; use --max-items to limit large lists.
- --dry-run on EC2 commands to test permissions without creating anything.

### SDKs

Every language has an SDK: **boto3** for Python, AWS SDK for JavaScript v3, Java, Go and more. They read credentials from the same default chain: environment variables, shared config files, SSO, then instance or task roles.

### Pitfalls

- Storing long-term access keys in ~/.aws/credentials on a shared machine.
- Running a destructive command against the wrong profile or region.
- Hardcoding keys in code instead of relying on the credential chain.

You are ready to move on when you can log in through SSO from the CLI, list your S3 buckets and EC2 instances in Mumbai, and write a ten-line boto3 script that does the same.

## Key concepts

- **AWS CLI v2 install**
- **aws configure sso and profiles**
- **sts get-caller-identity**
- **CloudShell**
- **--query and output formats**
- **boto3 (Python SDK)**
- **AWS SDK for JavaScript v3**
- **Credential provider chain**

## Mini project

Configure an SSO profile, then write a Python boto3 script that lists every region's running EC2 instances and unattached Elastic IPs, as a personal cost-leak checker. It only reads data, so it is free; run it after every lab.

## Check yourself

Your script works on your laptop but fails on an EC2 instance with 'Unable to locate credentials'. What is the right fix?

## Free resources

- [AWS CLI documentation](https://docs.aws.amazon.com/cli/) (AWS)
- [Boto3 documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) (AWS)
- [AWS CloudShell](https://docs.aws.amazon.com/cloudshell/) (AWS)

Previous: [Billing Safety: Budgets, Alerts and Cost Traps](https://www.internhack.in/roadmaps/tracks/cloud-engineer/billing-safety) · Next: [IAM Users, Groups, Roles and Policies](https://www.internhack.in/roadmaps/tracks/cloud-engineer/iam-fundamentals)

## More in AWS Account Setup and Billing Safety

- [Creating and Securing Your AWS Account](https://www.internhack.in/roadmaps/tracks/cloud-engineer/account-setup)
- [Billing Safety: Budgets, Alerts and Cost Traps](https://www.internhack.in/roadmaps/tracks/cloud-engineer/billing-safety)
- [AWS CLI, CloudShell and SDKs](https://www.internhack.in/roadmaps/tracks/cloud-engineer/aws-cli)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cloud Engineer (AWS) Roadmap](https://www.internhack.in/roadmaps/tracks/cloud-engineer)
