Master AWS CLI

Learn to control AWS infrastructure from your terminal. From installation to advanced automation.

Getting Started

Install and configure your CLI environment

Installation

Choose your OS and follow the instructions:

curl "https://awscli.amazonaws.com/AWSCLIV2-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
msiexec /i AWSCLIV2.msi
Download CLI →

Configuration

Run the configure command and enter your AWS credentials:

aws configure
Enter AWS Access Key ID: [your-key]
Enter AWS Secret Access Key: [your-secret]
Default region name: us-east-1
Default output format: json
Configuration Docs →

CLI Basics

Common commands and best practices

List Resources

aws ec2 describe-instances --query 'Reservations[*].Instances[*].{ID:InstanceId,Type:InstanceType}' --output table

Use JMESPath queries to extract specific fields from JSON outputs.

S3 Operations

aws s3 cp myfile.txt s3://my-bucke/
aws s3 sync . s3://my-bucket --exclude "*.tmp"

Copy and sync files with S3 using recursive and filtering options.

CloudFront

aws cloudfront create-invalidation
--distribution-id E23APVBMN4413U
--paths Items=/index.html,/error.html

Invalidate CloudFront cache to distribute updates immediately.

IAM & Roles

aws iam create-user --user-name dev-user
aws iam attach-user-policy
--policy-arn arn:aws:iam::123456789012:policy/DevAccess--user-name dev-user

Create users and attach policies directly from the command line.

Advanced Usage

Automation and scripting with AWS CLI

Scripting Integration

#!/bin/bash
INSTANCE_ID=$(aws ec2 run-instances \--image-id ami-123456 --count 1 --instance-type t2.micro |
jq -r .Instances[0].InstanceId)
echo Created instance $INSTANCE_ID

Use the CLI with shell scripts to automate complex workflows.

Output Formatting

aws ec2 describe-instances --output table
aws cloudtrail list-trails --output json

Choose output formats: json, text, table, or yaml

Multiple Profiles

aws configure --profile prod
aws s3 ls --profile prod

Manage multiple environments with separate credential profiles.

Filtering Queries

aws ec2 describe-images --owners self \|
jq '._Items[] | select(.State == "available")'

Use jq with CLI to extract and filter JSON data efficiently.

Need More Examples?

Explore full documentation and tutorials

View CLI Reference Docs →

Start Automating Your AWS

Leverage the power of the CLI for infrastructure automation, cost control, and security.