Choose an S3 storage class during upload
📑 On this page
Part 37 of AWS from Zero. This lesson keeps the scope to one S3 behavior you can verify from the terminal.
What we are learning
The storage class controls price and retrieval characteristics. STANDARD_IA suits infrequently accessed data that still needs millisecond retrieval.
Before you run it
aws sts get-caller-identity
REGION="ap-south-1"
BUCKET="replace-with-your-private-demo-bucket"Use a private general purpose bucket that you own. Replace every placeholder before running a write or delete command.
Cost note: Standard-IA has retrieval charges and a minimum storage duration. Use tiny demo objects and clean up knowingly.
The command
echo "storage class demo" > infrequent.txt
aws s3api put-object \
--bucket "$BUCKET" \
--key archive/infrequent.txt \
--body infrequent.txt \
--storage-class STANDARD_IAA successful configuration command may return no output. Treat inspection as a separate required step.
Inspect the result
aws s3api list-objects-v2 \
--bucket "$BUCKET" \
--prefix archive/infrequent.txt \
--query "Contents[].{Key:Key,Class:StorageClass,Size:Size}" \
--output tableRead the returned fields rather than assuming the write succeeded exactly as intended.
One tiny variation
aws s3api copy-object \
--bucket "$BUCKET" \
--copy-source "$BUCKET/archive/infrequent.txt" \
--key archive/standard-copy.txt \
--storage-class STANDARDA copy creates a new object whose storage class can differ from the source.
Common mistake
Storage classes can have minimum storage duration, minimum billable object size, and retrieval charges. Do not choose only by the per-GB storage price.
Cleanup
aws s3 rm "s3://$BUCKET/archive/infrequent.txt"
aws s3 rm "s3://$BUCKET/archive/standard-copy.txt"
rm infrequent.txtEarly deletion charges may still apply to minimum-duration storage classes.
Next, we will learn List S3 objects under one prefix.