What You Will Learn
Intermediate
- S3 versioning for data protection
- Lifecycle policies for cost optimization
- CORS for web access
Versioning protects you
Enable versioning on important buckets. If someone deletes a file, you can restore the previous version. Essential for production data.Terminalbash
# Enable versioning
aws s3api put-bucket-versioning \
--bucket my-bucket \
--versioning-configuration Status=Enabled
# List all versions
aws s3api list-object-versions --bucket my-bucketLifecycle Policies
Automatically move objects to cheaper storage:
| After | Move to | Cost savings |
|---|---|---|
| 30 days | Standard-IA | ~40% |
| 90 days | Glacier | ~80% |
| 365 days | Glacier Deep Archive | ~95% |
Practical Exercise
Enable versioning on a bucket
Upload a file, then upload a new version
List versions:
aws s3api list-object-versionsSet a lifecycle rule to move objects to IA after 30 days
Key Takeaways
- Versioning: keep all versions of an object — restore deleted files.
- Lifecycle: auto-move to cheaper storage classes.
- CORS: allow web browsers to access S3 directly.
- Always enable versioning on production buckets.
Comments
Comments
Post a Comment