New batchZero to DevOps starts 29 Nov · limited seatsReserve your seat
Cheat sheetsAWSAWS
FreeSheet 03 of 7

Storage Services

A comprehensive developer cheatsheet covering core AWS storage services, featuring essential CLI commands and management workflows for S3, EBS, EFS, Glacier, Storage Gateway, and AWS Backup.

S3 — Simple Storage Service

S3 is object storage for the cloud. It's highly durable, scalable, and secure.

S3 Storage Classes

ClassUse CaseDurabilityAvailability
S3 StandardFrequently accessed data99.999999999%99.99%
S3 Intelligent-TieringUnknown access patterns99.999999999%99.9%
S3 Standard-IAInfrequently accessed99.999999999%99.9%
S3 One Zone-IAInfrequent, non-critical99.999999999%99.5%
S3 Glacier Instant RetrievalLong-lived, rapid access99.999999999%99.9%
S3 Glacier Flexible RetrievalArchived, minutes to hours99.999999999%99.9%
S3 Glacier Deep ArchiveArchived, 12-48 hours99.999999999%99.9%

Basic S3 Operations

List S3 Buckets:

bash
$ aws s3 ls
2026-01-15 10:30:15 my-bucket
2026-01-15 10:30:20 logs-bucket
2026-01-15 10:30:25 static-assets

Lists all S3 buckets in your account.

List Objects in a Bucket:

bash
$ aws s3 ls s3://my-bucket/
2026-01-15 10:30:15   12345  file1.txt
2026-01-15 10:30:20   67890  file2.pdf
2026-01-15 10:30:25       0  images/
2026-01-15 10:30:30   23456  images/logo.png

Recursive List with Human-Readable Sizes:

bash
$ aws s3 ls s3://my-bucket/ --recursive --human-readable --summarize
2026-01-15 10:30:15   12.5 KiB file1.txt
2026-01-15 10:30:20   67.9 KiB file2.pdf
2026-01-15 10:30:30   23.5 KiB images/logo.png
2026-01-15 10:30:35  456.7 KiB images/banner.jpg

Total Objects: 4
   Total Size: 560.6 KiB

Uploading Files

Upload a Single File:

bash
$ aws s3 cp localfile.txt s3://my-bucket/
upload: ./localfile.txt to s3://my-bucket/localfile.txt

Uploads a local file to S3.

Upload with Specific Storage Class:

bash
$ aws s3 cp localfile.txt s3://my-bucket/ --storage-class STANDARD_IA

Upload with Server-Side Encryption:

bash
$ aws s3 cp localfile.txt s3://my-bucket/ --sse AES256

Upload with Metadata:

bash
$ aws s3 cp localfile.txt s3://my-bucket/ --metadata '{"key":"value","author":"bob"}'

Recursive Upload (Directory):

bash
$ aws s3 cp ./local-dir/ s3://my-bucket/ --recursive
upload: ./local-dir/file1.txt to s3://my-bucket/file1.txt
upload: ./local-dir/file2.txt to s3://my-bucket/file2.txt
upload: ./local-dir/subdir/file3.txt to s3://my-bucket/subdir/file3.txt

Multipart Upload (Large Files):

bash
$ aws s3 cp largefile.bin s3://my-bucket/ --multipart-chunksize 10M
(Uploads in 10MB chunks for better performance)

Downloading Files

Download a Single File:

bash
$ aws s3 cp s3://my-bucket/file.txt .
download: s3://my-bucket/file.txt to ./file.txt

Download with Different Name:

bash
$ aws s3 cp s3://my-bucket/file.txt downloaded_file.txt

Recursive Download (Directory):

bash
$ aws s3 cp s3://my-bucket/ ./local-dir/ --recursive
download: s3://my-bucket/file1.txt to ./local-dir/file1.txt
download: s3://my-bucket/file2.txt to ./local-dir/file2.txt

Syncing Directories

Sync Local to S3:

bash
$ aws s3 sync ./local-dir s3://my-bucket/
upload: ./local-dir/file1.txt to s3://my-bucket/file1.txt
upload: ./local-dir/file2.txt to s3://my-bucket/file2.txt

Synchronizes directories — only new/changed files are uploaded.

Sync S3 to Local:

bash
$ aws s3 sync s3://my-bucket/ ./local-dir/
download: s3://my-bucket/file1.txt to ./local-dir/file1.txt
download: s3://my-bucket/file2.txt to ./local-dir/file2.txt

Sync with Deletion (Remove Extra Files):

bash
$ aws s3 sync ./local-dir s3://my-bucket/ --delete
(Removes files from S3 that don't exist locally)

Exclude Files from Sync:

bash
$ aws s3 sync ./local-dir s3://my-bucket/ --exclude "*.tmp" --exclude "*.log"

Include Only Specific Files:

bash
$ aws s3 sync ./local-dir s3://my-bucket/ --include "*.txt" --include "*.pdf" --exclude "*"

Deleting Files

Delete a Single File:

bash
$ aws s3 rm s3://my-bucket/file.txt
delete: s3://my-bucket/file.txt

Recursive Delete (Directory):

bash
$ aws s3 rm s3://my-bucket/images/ --recursive
delete: s3://my-bucket/images/logo.png
delete: s3://my-bucket/images/banner.jpg

Delete Bucket (Must be empty):

bash
$ aws s3 rb s3://my-bucket
remove_bucket: my-bucket

Force Delete Bucket and Contents:

bash
$ aws s3 rb s3://my-bucket --force
delete: s3://my-bucket/file1.txt
delete: s3://my-bucket/file2.txt
remove_bucket: my-bucket

** Permanently deletes all objects and the bucket.**

Moving & Renaming

Move a File (Copy + Delete):

bash
$ aws s3 mv s3://my-bucket/file.txt s3://my-bucket/newdir/
move: s3://my-bucket/file.txt to s3://my-bucket/newdir/file.txt

Rename a File:

bash
$ aws s3 mv s3://my-bucket/oldname.txt s3://my-bucket/newname.txt

S3 Advanced Features

Presigned URLs

Generate a Presigned URL (Temporary Download Link):

bash
$ aws s3 presign s3://my-bucket/secret-file.pdf --expires-in 3600
https://my-bucket.s3.amazonaws.com/secret-file.pdf?AWSAccessKeyId=AKIA...&Expires=1705312215&Signature=...

Generates a time-limited URL for secure sharing. Default expires in 3600 seconds (1 hour).

Bucket Policies

Get Bucket Policy:

bash
$ aws s3api get-bucket-policy --bucket my-bucket
{
    "Policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"PublicRead\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::my-bucket/*\"}]}"
}

Put Bucket Policy (Make Public Read):

bash
$ aws s3api put-bucket-policy --bucket my-bucket --policy file://policy.json

Example policy.json:

json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicRead",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::my-bucket/*"
        }
    ]
}

Delete Bucket Policy:

bash
$ aws s3api delete-bucket-policy --bucket my-bucket

Bucket Versioning

Enable Versioning:

bash
$ aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=Enabled

Suspend Versioning:

bash
$ aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=Suspended

Get Versioning Status:

bash
$ aws s3api get-bucket-versioning --bucket my-bucket
{
    "Status": "Enabled"
}

List Object Versions:

bash
$ aws s3api list-object-versions --bucket my-bucket --prefix file.txt
{
    "Versions": [
        {
            "VersionId": "abc123",
            "LastModified": "2026-01-15T10:30:15.000Z",
            "Size": 1234
        },
        {
            "VersionId": "def456",
            "LastModified": "2026-01-14T10:30:15.000Z",
            "Size": 5678
        }
    ]
}

Delete Specific Version:

bash
$ aws s3api delete-object --bucket my-bucket --key file.txt --version-id abc123

Static Website Hosting

Enable Static Website Hosting:

bash
$ aws s3api put-bucket-website --bucket my-bucket --website-configuration file://website.json

Example website.json:

json
{
    "IndexDocument": {
        "Suffix": "index.html"
    },
    "ErrorDocument": {
        "Key": "404.html"
    }
}

Get Website URL:

bash
$ aws s3api get-bucket-website --bucket my-bucket
{
    "IndexDocument": {
        "Suffix": "index.html"
    },
    "ErrorDocument": {
        "Key": "404.html"
    }
}

Access at: http://my-bucket.s3-website-<region>.amazonaws.com

Lifecycle Rules

Get Lifecycle Configuration:

bash
$ aws s3api get-bucket-lifecycle-configuration --bucket my-bucket

Put Lifecycle Configuration:

bash
$ aws s3api put-bucket-lifecycle-configuration --bucket my-bucket --lifecycle-configuration file://lifecycle.json

Example lifecycle.json (Move to Glacier after 30 days):

json
{
    "Rules": [
        {
            "Id": "MoveToGlacier",
            "Status": "Enabled",
            "Filter": {
                "Prefix": "archive/"
            },
            "Transitions": [
                {
                    "Days": 30,
                    "StorageClass": "GLACIER"
                }
            ],
            "Expiration": {
                "Days": 365
            }
        }
    ]
}

Delete Lifecycle Configuration:

bash
$ aws s3api delete-bucket-lifecycle --bucket my-bucket

Server Access Logging

Enable Access Logging:

bash
$ aws s3api put-bucket-logging --bucket my-bucket --bucket-logging-status file://logging.json

Example logging.json:

json
{
    "LoggingEnabled": {
        "TargetBucket": "logs-bucket",
        "TargetPrefix": "my-bucket-logs/"
    }
}

CORS Configuration

Get CORS Configuration:

bash
$ aws s3api get-bucket-cors --bucket my-bucket

Put CORS Configuration:

bash
$ aws s3api put-bucket-cors --bucket my-bucket --cors-configuration file://cors.json

Example cors.json:

json
{
    "CORSRules": [
        {
            "AllowedOrigins": ["https://example.com"],
            "AllowedMethods": ["GET", "PUT", "POST", "DELETE"],
            "AllowedHeaders": ["*"],
            "MaxAgeSeconds": 3000
        }
    ]
}

S3 Glacier — Archival Storage

Glacier Management

List Vaults (Legacy Glacier):

bash
$ aws glacier list-vaults --account-id -
{
    "VaultList": [
        {
            "VaultName": "archive-vault",
            "VaultARN": "arn:aws:glacier:us-east-1:123456789012:vaults/archive-vault",
            "SizeInBytes": 1234567890,
            "NumberOfArchives": 5
        }
    ]
}

Create Vault:

bash
$ aws glacier create-vault --account-id - --vault-name new-vault
{
    "location": "/123456789012/vaults/new-vault"
}

Delete Vault:

bash
$ aws glacier delete-vault --account-id - --vault-name new-vault

Upload to S3 Glacier via S3 Lifecycle:

bash
$ aws s3 cp archive.tar.gz s3://my-archive-bucket/ --storage-class GLACIER

Restore from Glacier (Standard Retrieval - 3-5 hours):

bash
$ aws s3api restore-object \
    --bucket my-archive-bucket \
    --key archive.tar.gz \
    --restore-request Days=1,GlacierJobParameters={Tier=Standard}

Restore from Glacier (Expedited Retrieval - 1-5 minutes):

bash
$ aws s3api restore-object \
    --bucket my-archive-bucket \
    --key archive.tar.gz \
    --restore-request Days=1,GlacierJobParameters={Tier=Expedited}

Restore from Glacier (Bulk Retrieval - 5-12 hours):

bash
$ aws s3api restore-object \
    --bucket my-archive-bucket \
    --key archive.tar.gz \
    --restore-request Days=1,GlacierJobParameters={Tier=Bulk}

Check Restore Status:

bash
$ aws s3api head-object --bucket my-archive-bucket --key archive.tar.gz
{
    "Restore": "ongoing-request=\"true\"",
    "StorageClass": "GLACIER"
}

EBS — Elastic Block Store

EBS provides block-level storage for EC2 instances.

Volume Management

List EBS Volumes:

bash
$ aws ec2 describe-volumes --query 'Volumes[*].[VolumeId,Size,State,AvailabilityZone,Attachments[0].InstanceId]' --output table
|------------------|------|---------|------------------|------------------|
| vol-12345678     | 100  | in-use  | us-east-1a       | i-0dae5d4daa47fe4a2 |
| vol-87654321     | 50   | available| us-east-1b       | None             |

Create EBS Volume:

bash
$ aws ec2 create-volume --size 20 --availability-zone us-east-1a --volume-type gp3
{
    "VolumeId": "vol-abcdef1234567890",
    "Size": 20,
    "State": "creating",
    "AvailabilityZone": "us-east-1a",
    "VolumeType": "gp3"
}

Create Volume from Snapshot:

bash
$ aws ec2 create-volume --snapshot-id snap-1234567890abcdef0 --availability-zone us-east-1a

Attach Volume to Instance:

bash
$ aws ec2 attach-volume --volume-id vol-abcdef1234567890 --instance-id i-0dae5d4daa47fe4a2 --device /dev/sdf
{
    "VolumeId": "vol-abcdef1234567890",
    "State": "attaching"
}

Detach Volume from Instance:

bash
$ aws ec2 detach-volume --volume-id vol-abcdef1234567890
{
    "VolumeId": "vol-abcdef1234567890",
    "State": "detaching"
}

Delete Volume:

bash
$ aws ec2 delete-volume --volume-id vol-abcdef1234567890

** Volume must be detached before deletion.**

Resize Volume (Modify Size):

bash
$ aws ec2 modify-volume --volume-id vol-abcdef1234567890 --size 50
{
    "VolumeModification": {
        "VolumeId": "vol-abcdef1234567890",
        "ModificationState": "modifying",
        "OriginalSize": 20,
        "TargetSize": 50
    }
}

Snapshots

Create Snapshot from Volume:

bash
$ aws ec2 create-snapshot --volume-id vol-12345678 --description "Backup before update"
{
    "SnapshotId": "snap-1234567890abcdef0",
    "StartTime": "2026-01-15T10:30:15.000Z",
    "State": "pending",
    "VolumeSize": 100,
    "Description": "Backup before update"
}

List Snapshots:

bash
$ aws ec2 describe-snapshots --owner-ids self --query 'Snapshots[*].[SnapshotId,VolumeId,VolumeSize,StartTime]' --output table
|------------------|------------------|--------|----------------------|
| snap-1234567890abcdef0 | vol-12345678 | 100 | 2026-01-15T10:30:15.000Z |

Delete Snapshot:

bash
$ aws ec2 delete-snapshot --snapshot-id snap-1234567890abcdef0

Copy Snapshot to Another Region:

bash
$ aws ec2 copy-snapshot \
    --source-snapshot-id snap-1234567890abcdef0 \
    --source-region us-east-1 \
    --destination-region us-west-2 \
    --description "Copy of backup snapshot"

EFS — Elastic File System

EFS provides scalable file storage for EC2 instances (NFS).

File System Management

List EFS File Systems:

bash
$ aws efs describe-file-systems --query 'FileSystems[*].[FileSystemId,Name,SizeInBytes.Value]' --output table
|------------------|--------------|-----------------|
| fs-12345678      | web-storage  | 1234567890      |
| fs-87654321      | data-share   | 4567890123      |

Create EFS File System:

bash
$ aws efs create-file-system --creation-token my-fs --performance-mode generalPurpose
{
    "FileSystemId": "fs-abcdef1234567890",
    "CreationToken": "my-fs",
    "CreationTime": "2026-01-15T10:30:15.000Z",
    "LifeCycleState": "creating",
    "PerformanceMode": "generalPurpose"
}

Create Mount Target (Subnet):

bash
$ aws efs create-mount-target \
    --file-system-id fs-abcdef1234567890 \
    --subnet-id subnet-12345678 \
    --security-groups sg-12345678
{
    "MountTargetId": "fsmt-1234567890",
    "FileSystemId": "fs-abcdef1234567890",
    "SubnetId": "subnet-12345678",
    "LifeCycleState": "creating"
}

Mount EFS on EC2 Instance:

bash
$ sudo mkdir -p /mnt/efs
$ sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-abcdef1234567890.efs.us-east-1.amazonaws.com:/ /mnt/efs

Add to /etc/fstab (Auto-mount):

bash
$ echo "fs-abcdef1234567890.efs.us-east-1.amazonaws.com:/ /mnt/efs nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev 0 0" >> /etc/fstab

Delete EFS File System:

bash
$ aws efs delete-file-system --file-system-id fs-abcdef1234567890

** Must delete all mount targets first.**

Delete Mount Target:

bash
$ aws efs delete-mount-target --mount-target-id fsmt-1234567890

Storage Gateway

Storage Gateway connects on-premises environments to AWS storage.

List Gateways:

bash
$ aws storagegateway list-gateways --query 'Gateways[*].[GatewayName,GatewayARN,GatewayType]' --output table
|------------------|------------------------------------------|-------------|
| my-gateway       | arn:aws:storagegateway:us-east-1:123456789012:gateway/sgw-12345678 | FILE_S3 |

List Volumes:

bash
$ aws storagegateway list-volumes --gateway-arn arn:aws:storagegateway:us-east-1:123456789012:gateway/sgw-12345678

AWS Backup

AWS Backup centralizes backup management across AWS services.

List Backup Plans:

bash
$ aws backup list-backup-plans --query 'BackupPlans[*].[BackupPlanName,BackupPlanId]' --output table
|------------------|-------------------------------|
| daily-backup     | 12345678-1234-1234-1234-123456789012 |

List Backup Vaults:

bash
$ aws backup list-backup-vaults --query 'BackupVaults[*].[BackupVaultName]' --output table
|------------------|
| Default          |
| production-vault |

Start Backup Job:

bash
$ aws backup start-backup-job \
    --backup-vault-name default \
    --resource-arn arn:aws:ec2:us-east-1:123456789012:volume/vol-12345678 \
    --iam-role-arn arn:aws:iam::123456789012:role/AWSBackupDefaultRole
{
    "BackupJobId": "12345678-1234-1234-1234-123456789012"
}

List Backup Jobs:

bash
$ aws backup list-backup-jobs --query 'BackupJobs[*].[BackupJobId,ResourceType,State]' --output table

Restore from Backup:

bash
$ aws backup start-restore-job \
    --recovery-point-arn arn:aws:backup:us-east-1:123456789012:recovery-point:12345678-1234-1234-1234-123456789012 \
    --iam-role-arn arn:aws:iam::123456789012:role/AWSBackupDefaultRole \
    --metadata '{"VolumeId":"vol-12345678"}'

Quick Reference — Most Used Commands

TaskCommand
List S3 bucketsaws s3 ls
List objects in S3aws s3 ls s3://bucket/
Upload to S3aws s3 cp file.txt s3://bucket/
Download from S3aws s3 cp s3://bucket/file.txt .
Sync to S3aws s3 sync ./dir s3://bucket/
Sync with deleteaws s3 sync ./dir s3://bucket/ --delete
Delete S3 objectaws s3 rm s3://bucket/file.txt
Delete S3 bucketaws s3 rb s3://bucket --force
Generate presigned URLaws s3 presign s3://bucket/file --expires-in 3600
Enable versioningaws s3api put-bucket-versioning --bucket bucket --versioning-configuration Status=Enabled
List EBS volumesaws ec2 describe-volumes
Create EBS snapshotaws ec2 create-snapshot --volume-id vol-xxx --description "Backup"
List EFSaws efs describe-file-systems
Restore from Glacieraws s3api restore-object --bucket bucket --key file --restore-request Days=1
List backup vaultsaws backup list-backup-vaults

Additional Tips

  1. S3 is Eventually Consistent — after PUT/DELETE, reads may not reflect changes immediately.

  2. S3 Pricing:

  • Storage cost (per GB)
  • Request cost (PUT, GET, LIST)
  • Data transfer cost (out to internet)
  • Use S3 Intelligent-Tiering for unknown patterns.
  1. Lifecycle Rules — automatically move data to cheaper storage classes.

  2. EBS Multi-Attach — supports attaching to multiple EC2 instances (specific volume types only).

  3. EFS Mount Helpers — use amazon-efs-utils for easier mounting.

  4. Backup Plans — create automated backups with aws backup create-backup-plan.

  5. S3 Object Lock — prevent object deletion for compliance.

  6. Glacier Retrieval Times:

  • Expedited: 1-5 minutes
  • Standard: 3-5 hours
  • Bulk: 5-12 hours

Next in AWSDatabase Services Pro
AWS cheat sheet: Storage Services | InfraThrone DevOps Park