The AWS Command Line Interface (AWS CLI) is a unified tool to manage your AWS services.
Configuration
aws configure # Interactive prompt to set Access Key, Secret Key, Region, and Output format
aws configure list # List current configuration
aws configure --profile dev # Configure a specific profile named 'dev'S3 (Simple Storage Service)
aws s3 ls # List all buckets
aws s3 ls s3://my-bucket # List contents of a specific bucket
aws s3 mb s3://new-bucket # Create a new bucket
aws s3 cp file.txt s3://my-bucket/ # Upload a file to S3
aws s3 cp s3://my-bucket/file.txt . # Download a file from S3
aws s3 sync ./local-dir s3://my-bucket/ # Sync a local directory to an S3 bucket
aws s3 rm s3://my-bucket/file.txt # Delete a file from S3EC2 (Elastic Compute Cloud)
aws ec2 describe-instances # List all instances and their details (outputs large JSON)
aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId, State.Name, PublicIpAddress]" --output table # Formatted list
aws ec2 start-instances --instance-ids i-1234567890abcdef0 # Start an instance
aws ec2 stop-instances --instance-ids i-1234567890abcdef0 # Stop an instanceIAM (Identity and Access Management)
aws iam list-users # List all IAM users
aws iam create-user --user-name john.doe # Create a new user
aws iam list-access-keys --user-name john.doe # List access keys for a userSpecifying Profiles and Regions
If you have multiple AWS accounts or regions configured, you can override the defaults per command.
aws s3 ls --profile dev
aws ec2 describe-instances --region eu-west-1