</>
Skip to content
AWS lessons (6/47)

AWS — CLI

What is AWS CLI?

Command-line tool for managing AWS services programmatically.

Basic commands

# List S3 buckets
aws s3 ls

# Create S3 bucket
aws s3 mb s3://my-bucket

# Upload file
aws s3 cp file.txt s3://my-bucket/

# Download file
aws s3 cp s3://my-bucket/file.txt .

EC2 commands

# List instances
aws ec2 describe-instances

# Start instance
aws ec2 start-instances --instance-ids i-1234567890abcdef0

# Stop instance
aws ec2 stop-instances --instance-ids i-1234567890abcdef0

# Terminate instance
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0

IAM commands

# List users
aws iam list-users

# Create user
aws iam create-user --user-name newuser

# Attach policy
aws iam attach-user-policy --user-name newuser --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess

Output formats

# JSON (default)
aws s3 ls --output json

# Table
aws ec2 describe-instances --output table

# YAML
aws s3 ls --output yaml

Filtering

# Filter instances
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running"

# Query results
aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId,State.Name]"

Profiles

# Configure profile
aws configure --profile dev

# Use profile
aws s3 ls --profile dev

Helpful flags

  • --dry-run: Preview changes
  • --no-paginate: Disable pagination
  • --max-items: Limit results

Mini Practice

  1. List S3 buckets
  2. Create an EC2 instance
  3. Use filters and queries
  4. Set up profiles

Up Next

Continue with IAM - Identity and Access Management.

Related Topics

Frequently Asked Questions about CLI

What is CLI in AWS?

CLI is a fundamental concept in AWS. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn CLI?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn CLI.

Why is CLI important in AWS?

CLI is essential for AWS development. Understanding this concept will help you write better code and solve real-world problems more effectively.