# S3 Security, Encryption and Lifecycle Rules

> Prevent public data leaks with Block Public Access and bucket policies, encrypt data, replicate it, and automate cost savings with lifecycle rules. Free notes,...

Canonical: https://www.internhack.in/roadmaps/tracks/cloud-engineer/s3-security-lifecycle
Last updated: 2026-11-28

Prevent public data leaks with Block Public Access and bucket policies, encrypt data, replicate it, and automate cost savings with lifecycle rules.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [Amazon S3 Fundamentals](https://www.internhack.in/roadmaps/tracks/cloud-engineer/s3-fundamentals), [Policy Evaluation, Conditions and Resource Policies](https://www.internhack.in/roadmaps/tracks/cloud-engineer/iam-policy-evaluation)

Public S3 buckets have leaked millions of records worldwide, including from Indian companies. Today AWS defaults are safe, but you must understand them so you never undo them by accident.

### Access control

- **Block Public Access** is on by default at account and bucket level. Leave it on unless the bucket truly serves public content, and even then prefer CloudFront with OAC.
- **Object Ownership: bucket owner enforced** disables ACLs; use policies only.
- **Bucket policies** for cross-account access, HTTPS-only (aws:SecureTransport) and VPC endpoint restrictions.

### Encryption

- All new objects are encrypted at rest by default with **SSE-S3**.
- **SSE-KMS** uses KMS keys for audit trails and finer control; enable **S3 Bucket Keys** to cut KMS request costs.
- Enforce TLS in transit with a bucket policy.

### Lifecycle and data protection

- **Lifecycle rules**: move objects to IA after 30 days, Glacier after 90, delete after a year; expire old versions and incomplete multipart uploads.
- **Replication** (same-region or cross-region, for example Mumbai to Hyderabad) for DR and compliance.
- **Object Lock** for write-once-read-many retention, useful against ransomware.
- **MFA Delete** for extra protection on versioned buckets.

### Pitfalls

- Turning off Block Public Access to "fix" a CloudFront 403 error.
- Lifecycle transitions on tiny objects, which can cost more than they save.

You are ready to move on when you can write a bucket policy that enforces HTTPS and denies access from outside your VPC endpoint, and a lifecycle rule that expires old versions.

## Key concepts

- **Block Public Access**
- **Bucket policies**
- **SSE-S3 vs SSE-KMS**
- **Lifecycle rules**
- **Cross-region replication**
- **Object Lock**
- **S3 access logs and CloudTrail data events**

## Mini project

On a versioned bucket, add a lifecycle rule that moves objects to Standard-IA after 30 days and deletes noncurrent versions after 7, plus a bucket policy denying non-HTTPS requests. Test the deny with curl over http. Keep only a few KB of data so it stays in free tier, and delete the bucket after.

## Check yourself

A developer disabled Block Public Access because CloudFront returned 403. What should they have done instead?

## Free resources

- [Blocking public access to S3 storage](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html) (AWS)
- [Managing the lifecycle of objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html) (AWS)
- [Security best practices for Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/security-best-practices.html) (AWS)

Previous: [Amazon S3 Fundamentals](https://www.internhack.in/roadmaps/tracks/cloud-engineer/s3-fundamentals) · Next: [Block and File Storage: EBS and EFS](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ebs-efs)

## More in Storage: S3, EBS and EFS

- [Amazon S3 Fundamentals](https://www.internhack.in/roadmaps/tracks/cloud-engineer/s3-fundamentals)
- [S3 Security, Encryption and Lifecycle Rules](https://www.internhack.in/roadmaps/tracks/cloud-engineer/s3-security-lifecycle)
- [Block and File Storage: EBS and EFS](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ebs-efs)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cloud Engineer (AWS) Roadmap](https://www.internhack.in/roadmaps/tracks/cloud-engineer)
