Learn to control AWS infrastructure from your terminal. From installation to advanced automation.
Install and configure your CLI environment
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
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
Common commands and best practices
aws ec2 describe-instances --query 'Reservations[*].Instances[*].{ID:InstanceId,Type:InstanceType}' --output table
Use JMESPath queries to extract specific fields from JSON outputs.
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.
aws cloudfront create-invalidation
--distribution-id E23APVBMN4413U
--paths Items=/index.html,/error.html
Invalidate CloudFront cache to distribute updates immediately.
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.
Automation and scripting with AWS CLI
#!/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.
aws ec2 describe-instances --output table
aws cloudtrail list-trails --output json
Choose output formats: json
, text
, table
, or yaml
aws configure --profile prod
aws s3 ls --profile prod
Manage multiple environments with separate credential profiles.
aws ec2 describe-images --owners self \|
jq '._Items[] | select(.State == "available")'
Use jq
with CLI to extract and filter JSON data efficiently.
Leverage the power of the CLI for infrastructure automation, cost control, and security.