Storage: S3, EBS & EFS
Verified against aws-cli/2.33.6, flags verified via `aws <cmd> help`, 2026-08-20 · official docs
S3 object and bucket operations, EBS volume/snapshot management for EC2, and EFS shared file systems.
S3 — copying, syncing, and listing objects#
aws s3 cp file.txt s3://my-bucket/path/file.txt aws s3 cp s3://my-bucket/path/file.txt ./file.txt aws s3 sync ./local-dir s3://my-bucket/path/ --delete # mirror local -> bucket, remove extras in the destination aws s3 sync s3://my-bucket/path/ ./local-dir aws s3 ls s3://my-bucket/path/ --recursive --human-readable --summarize
The high-level aws s3 commands (cp, sync, ls, rm, mb, rb) are convenience wrappers over the S3 API — they handle multipart upload/download automatically. --dryrun on cp/sync/rm previews what would change without doing it.
S3 — removing objects and buckets#
aws s3 rm s3://my-bucket/path/file.txt aws s3 rm s3://my-bucket/path/ --recursive # delete everything under a prefix aws s3 rb s3://my-bucket --force # delete a bucket, --force empties it first
S3 — bucket configuration (s3api)#
aws s3api create-bucket --bucket my-new-bucket --create-bucket-configuration LocationConstraint=us-west-2 aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=Enabled aws s3api put-bucket-policy --bucket my-bucket --policy file://bucket-policy.json aws s3api head-object --bucket my-bucket --key path/file.txt # metadata only, no download
Anything below the aws s3 convenience layer — bucket policies, versioning, lifecycle rules, ACLs, encryption config — lives under aws s3api, which maps 1:1 to the raw S3 API and needs --bucket/--key explicitly rather than an s3:// URI.
S3 — listing with s3api for scripting#
aws s3api list-objects-v2 --bucket my-bucket --prefix path/ --query 'Contents[].Key' --output text
s3api list-objects-v2 is the scriptable equivalent of aws s3 ls — prefer it when you need --query filtering or pagination control that the high-level ls doesn't expose.
EBS — creating and attaching volumes#
aws ec2 create-volume --availability-zone us-east-1a --size 100 --volume-type gp3 aws ec2 attach-volume --volume-id vol-0123456789abcdef0 --instance-id i-0123456789abcdef0 --device /dev/xvdf aws ec2 describe-volumes --volume-ids vol-0123456789abcdef0 aws ec2 delete-volume --volume-id vol-0123456789abcdef0
A volume must be in the same Availability Zone as the instance it attaches to — a common source of "InvalidVolume.ZoneMismatch" errors when scripting instance + volume creation together.
EBS — snapshots#
aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 --description "pre-migration backup" aws ec2 describe-snapshots --owner-ids self aws ec2 describe-snapshots --filters "Name=volume-id,Values=vol-0123456789abcdef0"
EFS — file systems and mount targets#
aws efs create-file-system --performance-mode generalPurpose --throughput-mode bursting --encrypted aws efs describe-file-systems aws efs create-mount-target --file-system-id fs-0123456789abcdef0 --subnet-id subnet-0123456789abcdef0 --security-groups sg-0123456789abcdef0 aws efs describe-mount-targets --file-system-id fs-0123456789abcdef0
EFS needs one mount target per Availability Zone you want to mount from — an EC2 instance in a subnet with no mount target for that file system will time out trying to mount it, not fail with a clear error.