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
| Class | Use Case | Durability | Availability |
|---|---|---|---|
| S3 Standard | Frequently accessed data | 99.999999999% | 99.99% |
| S3 Intelligent-Tiering | Unknown access patterns | 99.999999999% | 99.9% |
| S3 Standard-IA | Infrequently accessed | 99.999999999% | 99.9% |
| S3 One Zone-IA | Infrequent, non-critical | 99.999999999% | 99.5% |
| S3 Glacier Instant Retrieval | Long-lived, rapid access | 99.999999999% | 99.9% |
| S3 Glacier Flexible Retrieval | Archived, minutes to hours | 99.999999999% | 99.9% |
| S3 Glacier Deep Archive | Archived, 12-48 hours | 99.999999999% | 99.9% |
Basic S3 Operations
List S3 Buckets:
$ 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-assetsLists all S3 buckets in your account.
List Objects in a Bucket:
$ 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.pngRecursive List with Human-Readable Sizes:
$ 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 KiBUploading Files
Upload a Single File:
$ aws s3 cp localfile.txt s3://my-bucket/
upload: ./localfile.txt to s3://my-bucket/localfile.txtUploads a local file to S3.
Upload with Specific Storage Class:
$ aws s3 cp localfile.txt s3://my-bucket/ --storage-class STANDARD_IAUpload with Server-Side Encryption:
$ aws s3 cp localfile.txt s3://my-bucket/ --sse AES256Upload with Metadata:
$ aws s3 cp localfile.txt s3://my-bucket/ --metadata '{"key":"value","author":"bob"}'Recursive Upload (Directory):
$ 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.txtMultipart Upload (Large Files):
$ aws s3 cp largefile.bin s3://my-bucket/ --multipart-chunksize 10M
(Uploads in 10MB chunks for better performance)Downloading Files
Download a Single File:
$ aws s3 cp s3://my-bucket/file.txt .
download: s3://my-bucket/file.txt to ./file.txtDownload with Different Name:
$ aws s3 cp s3://my-bucket/file.txt downloaded_file.txtRecursive Download (Directory):
$ 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.txtSyncing Directories
Sync Local to S3:
$ 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.txtSynchronizes directories — only new/changed files are uploaded.
Sync S3 to Local:
$ 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.txtSync with Deletion (Remove Extra Files):
$ aws s3 sync ./local-dir s3://my-bucket/ --delete
(Removes files from S3 that don't exist locally)Exclude Files from Sync:
$ aws s3 sync ./local-dir s3://my-bucket/ --exclude "*.tmp" --exclude "*.log"Include Only Specific Files:
$ aws s3 sync ./local-dir s3://my-bucket/ --include "*.txt" --include "*.pdf" --exclude "*"Deleting Files
Delete a Single File:
$ aws s3 rm s3://my-bucket/file.txt
delete: s3://my-bucket/file.txtRecursive Delete (Directory):
$ aws s3 rm s3://my-bucket/images/ --recursive
delete: s3://my-bucket/images/logo.png
delete: s3://my-bucket/images/banner.jpgDelete Bucket (Must be empty):
$ aws s3 rb s3://my-bucket
remove_bucket: my-bucketForce Delete Bucket and Contents:
$ 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):
$ aws s3 mv s3://my-bucket/file.txt s3://my-bucket/newdir/
move: s3://my-bucket/file.txt to s3://my-bucket/newdir/file.txtRename a File:
$ aws s3 mv s3://my-bucket/oldname.txt s3://my-bucket/newname.txtS3 Advanced Features
Presigned URLs
Generate a Presigned URL (Temporary Download Link):
$ 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:
$ 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):
$ aws s3api put-bucket-policy --bucket my-bucket --policy file://policy.jsonExample policy.json:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}Delete Bucket Policy:
$ aws s3api delete-bucket-policy --bucket my-bucketBucket Versioning
Enable Versioning:
$ aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=EnabledSuspend Versioning:
$ aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=SuspendedGet Versioning Status:
$ aws s3api get-bucket-versioning --bucket my-bucket
{
"Status": "Enabled"
}List Object Versions:
$ 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:
$ aws s3api delete-object --bucket my-bucket --key file.txt --version-id abc123Static Website Hosting
Enable Static Website Hosting:
$ aws s3api put-bucket-website --bucket my-bucket --website-configuration file://website.jsonExample website.json:
{
"IndexDocument": {
"Suffix": "index.html"
},
"ErrorDocument": {
"Key": "404.html"
}
}Get Website URL:
$ 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:
$ aws s3api get-bucket-lifecycle-configuration --bucket my-bucketPut Lifecycle Configuration:
$ aws s3api put-bucket-lifecycle-configuration --bucket my-bucket --lifecycle-configuration file://lifecycle.jsonExample lifecycle.json (Move to Glacier after 30 days):
{
"Rules": [
{
"Id": "MoveToGlacier",
"Status": "Enabled",
"Filter": {
"Prefix": "archive/"
},
"Transitions": [
{
"Days": 30,
"StorageClass": "GLACIER"
}
],
"Expiration": {
"Days": 365
}
}
]
}Delete Lifecycle Configuration:
$ aws s3api delete-bucket-lifecycle --bucket my-bucketServer Access Logging
Enable Access Logging:
$ aws s3api put-bucket-logging --bucket my-bucket --bucket-logging-status file://logging.jsonExample logging.json:
{
"LoggingEnabled": {
"TargetBucket": "logs-bucket",
"TargetPrefix": "my-bucket-logs/"
}
}CORS Configuration
Get CORS Configuration:
$ aws s3api get-bucket-cors --bucket my-bucketPut CORS Configuration:
$ aws s3api put-bucket-cors --bucket my-bucket --cors-configuration file://cors.jsonExample cors.json:
{
"CORSRules": [
{
"AllowedOrigins": ["https://example.com"],
"AllowedMethods": ["GET", "PUT", "POST", "DELETE"],
"AllowedHeaders": ["*"],
"MaxAgeSeconds": 3000
}
]
}S3 Glacier — Archival Storage
Glacier Management
List Vaults (Legacy Glacier):
$ 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:
$ aws glacier create-vault --account-id - --vault-name new-vault
{
"location": "/123456789012/vaults/new-vault"
}Delete Vault:
$ aws glacier delete-vault --account-id - --vault-name new-vaultGlacier through S3 API (Recommended)
Upload to S3 Glacier via S3 Lifecycle:
$ aws s3 cp archive.tar.gz s3://my-archive-bucket/ --storage-class GLACIERRestore from Glacier (Standard Retrieval - 3-5 hours):
$ 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):
$ 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):
$ aws s3api restore-object \
--bucket my-archive-bucket \
--key archive.tar.gz \
--restore-request Days=1,GlacierJobParameters={Tier=Bulk}Check Restore Status:
$ 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:
$ 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:
$ 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:
$ aws ec2 create-volume --snapshot-id snap-1234567890abcdef0 --availability-zone us-east-1aAttach Volume to Instance:
$ aws ec2 attach-volume --volume-id vol-abcdef1234567890 --instance-id i-0dae5d4daa47fe4a2 --device /dev/sdf
{
"VolumeId": "vol-abcdef1234567890",
"State": "attaching"
}Detach Volume from Instance:
$ aws ec2 detach-volume --volume-id vol-abcdef1234567890
{
"VolumeId": "vol-abcdef1234567890",
"State": "detaching"
}Delete Volume:
$ aws ec2 delete-volume --volume-id vol-abcdef1234567890** Volume must be detached before deletion.**
Resize Volume (Modify Size):
$ 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:
$ 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:
$ 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:
$ aws ec2 delete-snapshot --snapshot-id snap-1234567890abcdef0Copy Snapshot to Another Region:
$ 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:
$ 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:
$ 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):
$ 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:
$ 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/efsAdd to /etc/fstab (Auto-mount):
$ 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/fstabDelete EFS File System:
$ aws efs delete-file-system --file-system-id fs-abcdef1234567890** Must delete all mount targets first.**
Delete Mount Target:
$ aws efs delete-mount-target --mount-target-id fsmt-1234567890Storage Gateway
Storage Gateway connects on-premises environments to AWS storage.
List Gateways:
$ 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:
$ aws storagegateway list-volumes --gateway-arn arn:aws:storagegateway:us-east-1:123456789012:gateway/sgw-12345678AWS Backup
AWS Backup centralizes backup management across AWS services.
List Backup Plans:
$ aws backup list-backup-plans --query 'BackupPlans[*].[BackupPlanName,BackupPlanId]' --output table
|------------------|-------------------------------|
| daily-backup | 12345678-1234-1234-1234-123456789012 |List Backup Vaults:
$ aws backup list-backup-vaults --query 'BackupVaults[*].[BackupVaultName]' --output table
|------------------|
| Default |
| production-vault |Start Backup Job:
$ 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:
$ aws backup list-backup-jobs --query 'BackupJobs[*].[BackupJobId,ResourceType,State]' --output tableRestore from Backup:
$ 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
| Task | Command |
|---|---|
| List S3 buckets | aws s3 ls |
| List objects in S3 | aws s3 ls s3://bucket/ |
| Upload to S3 | aws s3 cp file.txt s3://bucket/ |
| Download from S3 | aws s3 cp s3://bucket/file.txt . |
| Sync to S3 | aws s3 sync ./dir s3://bucket/ |
| Sync with delete | aws s3 sync ./dir s3://bucket/ --delete |
| Delete S3 object | aws s3 rm s3://bucket/file.txt |
| Delete S3 bucket | aws s3 rb s3://bucket --force |
| Generate presigned URL | aws s3 presign s3://bucket/file --expires-in 3600 |
| Enable versioning | aws s3api put-bucket-versioning --bucket bucket --versioning-configuration Status=Enabled |
| List EBS volumes | aws ec2 describe-volumes |
| Create EBS snapshot | aws ec2 create-snapshot --volume-id vol-xxx --description "Backup" |
| List EFS | aws efs describe-file-systems |
| Restore from Glacier | aws s3api restore-object --bucket bucket --key file --restore-request Days=1 |
| List backup vaults | aws backup list-backup-vaults |
Additional Tips
-
S3 is Eventually Consistent — after PUT/DELETE, reads may not reflect changes immediately.
-
S3 Pricing:
- Storage cost (per GB)
- Request cost (PUT, GET, LIST)
- Data transfer cost (out to internet)
- Use S3 Intelligent-Tiering for unknown patterns.
-
Lifecycle Rules — automatically move data to cheaper storage classes.
-
EBS Multi-Attach — supports attaching to multiple EC2 instances (specific volume types only).
-
EFS Mount Helpers — use
amazon-efs-utilsfor easier mounting. -
Backup Plans — create automated backups with
aws backup create-backup-plan. -
S3 Object Lock — prevent object deletion for compliance.
-
Glacier Retrieval Times:
- Expedited: 1-5 minutes
- Standard: 3-5 hours
- Bulk: 5-12 hours