AWS S3 cp: Upload a File to S3

Upload a local file to an S3 bucket using aws s3 cp. Covers basic upload syntax, storage classes, ACL options, and recursive directory uploads.

S3 Operations

Detailed Explanation

Uploading Files to S3 with aws s3 cp

The aws s3 cp command copies files between your local filesystem and Amazon S3. It is the most common way to upload and download individual files.

Basic Upload Command

aws s3 cp ./backup.tar.gz s3://my-backup-bucket/daily/backup.tar.gz

This copies backup.tar.gz from the current directory to the daily/ prefix in the my-backup-bucket bucket.

Upload with Options

aws s3 cp ./report.pdf s3://my-bucket/reports/report.pdf \
  --storage-class STANDARD_IA \
  --acl private \
  --region us-west-2

Key Flags

Flag Purpose
--recursive Copy entire directories instead of single files
--exclude Skip files matching a pattern (e.g., "*.log")
--include Include only files matching a pattern
--storage-class Choose storage tier (STANDARD, STANDARD_IA, GLACIER, etc.)
--acl Set access control (private, public-read, etc.)

Recursive Directory Upload

aws s3 cp ./website/ s3://my-website-bucket/ --recursive --exclude "*.tmp"

This uploads all files in the website/ directory except .tmp files. Unlike s3 sync, s3 cp --recursive does not delete files in the destination that are not in the source.

Download (Reverse Direction)

aws s3 cp s3://my-bucket/data/export.csv ./downloads/

The direction is determined by which argument is the S3 URI and which is the local path.

Use Case

Uploading application build artifacts, database backups, log archives, or static website assets to S3 buckets as part of CI/CD pipelines or manual deployment workflows.

Try It — AWS CLI Command Builder

Open full tool