Force SSL on Amazon S3
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Forcing SSL on S3 means rejecting any request that arrives over plain HTTP and allowing only HTTPS. The usual way to do that is not a checkbox in the bucket settings, but a bucket policy that denies requests when the AWS aws:SecureTransport condition is false.
Why HTTPS Enforcement Matters
S3 already supports HTTPS, but support is not the same as enforcement. If clients can still use HTTP, then data in transit is exposed to interception or tampering.
HTTPS enforcement matters for:
- Uploads containing sensitive data
- Downloads consumed by browsers or mobile apps
- Compliance controls that require encrypted transport
- Shared buckets accessed by many tools and teams
The goal is simple: make insecure transport impossible, not merely discouraged.
Enforce SSL With a Bucket Policy
The standard S3 approach is to attach a deny policy to the bucket.
This policy does not grant access. It explicitly denies all S3 actions when the request is not using secure transport. In AWS policy evaluation, an explicit deny wins.
Apply the Policy
You can add the policy in the S3 console, through CloudFormation, Terraform, or the AWS CLI.
With the CLI:
After that, HTTP requests should fail while HTTPS requests continue working if the caller is otherwise authorized.
Test the Behavior
After you apply the policy, verify both paths:
- An HTTPS request should succeed if the IAM permissions are correct
- An HTTP request should be denied
That test matters because it confirms you are not just relying on intended configuration but on actual runtime behavior.
If your access path goes through CloudFront, the same principle applies, but S3 bucket policy and CloudFront viewer protocol settings solve different parts of the transport chain. S3 policy protects direct bucket access. CloudFront settings protect the edge-to-viewer path.
Watch for Exceptions and AWS Service Access
In some architectures, AWS services or integrations access S3 on your behalf. The secure-transport deny is still the right default, but review service integrations if a workflow stops working after enforcement. The important question is whether the access path is genuinely HTTPS and whether the calling principal still has the required permissions.
Do not weaken the deny policy unless you have a specific, justified exception and understand the transport implications.
Keep the Policy in Infrastructure Code
Because HTTPS enforcement is a security control, it is usually best managed in Terraform, CloudFormation, or another infrastructure workflow rather than by hand in the console. That makes reviews, drift detection, and environment promotion much safer.
Common Pitfalls
- Assuming "S3 supports HTTPS" means HTTP is already blocked is incorrect.
- Applying the deny policy only to the bucket ARN and forgetting the object ARN leaves object requests uncovered.
- Mixing allow and deny statements without understanding evaluation order can make policy debugging harder.
- Protecting CloudFront with HTTPS does not automatically stop direct HTTP access to the bucket unless the bucket policy also denies insecure transport.
Summary
- Force SSL on S3 by denying requests where
aws:SecureTransportisfalse. - Apply the policy to both the bucket ARN and the object ARN pattern.
- Test both HTTPS success and HTTP failure after deployment.
- Treat HTTPS enforcement at S3 and HTTPS enforcement at CloudFront as related but separate controls.
Related reading
- Formatting DynamoDB data to normal JSON in AWS Lambda
- Forward and Backward Pagination in DynamoDB
- Fulltext Search DynamoDB
- Function not found after manually deleting a function in a SAM CloudFormation stack
- Format a date using the new date time API
- Formatting IPv6 as an int in C and storing it in SQL Server
- Generate SHA-1 for Flutter/React-Native/Android-Native app
- Generating unique, hard-to-guess coupon codes

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.