The AWS CLI & SDKs (boto3)
The AWS Command Line Interface (CLI) lets you manage AWS by typing commands, and the AWS SDKs let your own programs do the same. For Python, the SDK is called boto3. Both are faster than clicking once you know them, and both make your work repeatable.
Installing the CLI (version 2)
Always install AWS CLI version 2; version 1 is older and differs in places.
- Windows: download and run the official MSI installer from the AWS CLI documentation.
- macOS: run the official
.pkginstaller. - Linux (x86_64):
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install aws --version
Your version numbers will differ. AWS CloudShell, a browser terminal in the console, comes with the CLI preinstalled and already signed in, which is handy when you cannot install software.
Signing in: two ways
Recommended: IAM Identity Center (SSO)
If you set up Identity Center (see Creating an AWS Account Safely), run aws configure sso once. It asks for your access portal URL, opens a browser to approve the login, lets you pick an account and permission set, and saves a named profile:
$ aws configure sso SSO session name (Recommended): kuza SSO start URL [None]: https://d-1234567890.awsapps.com/start SSO region [None]: eu-west-1 SSO registration scopes [sso:account:access]: (browser opens; approve the request) There are 2 roles available to you. (use the arrow keys to choose AdministratorAccess) Default client Region [None]: eu-west-1 CLI default output format (json if not specified) [None]: json Profile name [AdministratorAccess-123456789012]: kuza-admin
Afterwards, when your session expires, log in again with one command:
aws sso login --profile kuza-admin
The CLI caches short-lived credentials and refreshes them; nothing permanent is stored on your laptop.
Fallback: access keys with aws configure
If you must use an IAM user's access key, aws configure stores it:
$ aws configure AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY Default region name [None]: eu-west-1 Default output format [None]: json
These are AWS's documentation dummy values. The key is saved in plain text in ~/.aws/credentials, and settings in ~/.aws/config. Keep those files out of every Git repository.
Your first commands
Check who you are signed in as. This is the first thing to run when something behaves strangely:
aws sts get-caller-identity --profile kuza-admin
To avoid typing --profile every time, set an environment variable for the session with export AWS_PROFILE=kuza-admin (macOS/Linux) or $env:AWS_PROFILE = "kuza-admin" (PowerShell).
Working with S3 (the outputs depend on your account and are examples):
aws s3 mb s3://kuza-notes-demo-2026 aws s3 cp results.csv s3://kuza-notes-demo-2026/reports/results.csv aws s3 ls aws s3 ls s3://kuza-notes-demo-2026/reports/
The aws s3 commands are high-level helpers. The aws s3api commands map one-to-one to the S3 API and give you every option:
aws s3api head-object --bucket kuza-notes-demo-2026 --key reports/results.csv
Shaping output with --query and --output
--query filters JSON using JMESPath, and --output chooses json, yaml, text or table. The instances shown are an example:
aws ec2 describe-instances \
--query "Reservations[].Instances[].[InstanceId, InstanceType, State.Name]" \
--output table
Other useful global options are --region and --no-cli-pager (stops the CLI opening long output in a pager).
boto3: AWS from Python
python -m pip install boto3
boto3 finds credentials automatically, in this order of common sources: environment variables, your ~/.aws profiles (including SSO profiles), then the role of the container, Lambda function or EC2 instance it runs on. That is why the same code works on your laptop and on AWS without any keys inside it.
import boto3
from botocore.exceptions import ClientError
session = boto3.Session(profile_name="kuza-admin", region_name="eu-west-1")
s3 = session.client("s3")
# List buckets
response = s3.list_buckets()
for bucket in response["Buckets"]:
print(bucket["Name"], bucket["CreationDate"].date())
# Upload a file
try:
s3.upload_file("results.csv", "kuza-notes-demo-2026", "reports/results.csv")
print("Uploaded reports/results.csv")
except ClientError as err:
print("Upload failed:", err.response["Error"]["Code"])
# A link that lets someone download the file for one hour
url = s3.generate_presigned_url(
"get_object",
Params={"Bucket": "kuza-notes-demo-2026", "Key": "reports/results.csv"},
ExpiresIn=3600,
)
print(url[:60] + "...")
This output is an example; your bucket list depends on your account, and the exact URL format can vary by Region and settings. When your code runs on AWS, drop profile_name and just call boto3.client("s3") so the role's credentials are used.
boto3 has two styles: clients (boto3.client("s3")), which map directly to API operations and return dictionaries, and resources (boto3.resource("dynamodb")), a more object-oriented layer. AWS no longer adds new features to resources, so prefer clients for new code; the DynamoDB Table resource is still common because it handles data types neatly.
Writing boto3.client("s3", aws_access_key_id="AKIA...", aws_secret_access_key="...") in your script. The keys end up in Git sooner or later. Let boto3 find credentials from your profile or role instead.
Key points
- Install AWS CLI v2, or use CloudShell in the browser.
- Prefer
aws configure ssoprofiles (short-lived credentials) overaws configurewith access keys. - Run
aws sts get-caller-identityto check which identity and account you are using. - Use
--query,--output,--regionand--profileto control commands. - boto3 finds credentials automatically, so never hard-code keys in Python.
Tip: use the ← and → keys to move between pages.
