Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable SSL-only policy if ACM certificate given #179

Closed
wants to merge 1 commit into from

Conversation

emyller
Copy link
Contributor

@emyller emyller commented Aug 6, 2021

what

  • Disables SSL-only requests restriction at S3 static-website settings when Cloudfront will handle TLS given an ACM certificate.

why

  • There is a conflict when setting up both CDN-level TLS and S3-level SSL, which makes S3 respond with a HTTP 403 error.

references

@emyller emyller requested review from a team as code owners August 6, 2021 21:33
@emyller
Copy link
Contributor Author

emyller commented Aug 6, 2021

To maintainers: can you please explain a use case justifying allow_ssl_requests_only=true since this module includes a Cloudfront CDN with TLS settings of its own? Thanks!

@osterman
Copy link
Member

osterman commented Aug 7, 2021

When deploying AWS Config and SecurityHub with the AWS Well-Architected Best Practices, it will raise an issue if TLS on a bucket is not mandatory.

@osterman
Copy link
Member

osterman commented Aug 7, 2021

If the module has problems with this enabled, then I suspect we have a cloud front misconfiguration for the origin, since I can't see why it should ever send non TLS requests.

@emyller
Copy link
Contributor Author

emyller commented Aug 9, 2021

If the module has problems with this enabled, then I suspect we have a cloud front misconfiguration for the origin, since I can't see why it should ever send non TLS requests.

Gotcha. My guess is that Cloudfront would communicate internally with S3, similarly to an ALB when it communicates with the hosts within a target group -- both scenarios not needing TLS. I can see a flaw in the Cloudfront-S3 scenario though: in case someone has the bucket name, they could make requests without TLS.

I can help investigating why the origin fails making TLS requests to S3 in a case like #175. I doesn't happen everywhere -- I've used this module before and didn't see this issue.

@dawilk
Copy link

dawilk commented Jul 9, 2022

If the module has problems with this enabled, then I suspect we have a cloud front misconfiguration for the origin, since I can't see why it should ever send non TLS requests.

Gotcha. My guess is that Cloudfront would communicate internally with S3, similarly to an ALB when it communicates with the hosts within a target group -- both scenarios not needing TLS. I can see a flaw in the Cloudfront-S3 scenario though: in case someone has the bucket name, they could make requests without TLS.

I can help investigating why the origin fails making TLS requests to S3 in a case like #175. I doesn't happen everywhere -- I've used this module before and didn't see this issue.

I believe the issue is with the default origin protocol policy here: https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/blob/master/main.tf#L413
the origin generated by the default s3_origins var will have this problem - it gets forced to http-only but the bucket gets a policy to Deny http-only. I think a fix would be to have the default set to match-viewer (the AWS default) and then let allow_ssl_requests_only=true change it to https-only.
I'd even be in favor of keeping allow_ssl_requests_only=true as default but make sure the origin_protocol_policy on the resource is set appropriately to align with the bucket policy.

@hans-d hans-d added the stale This PR has gone stale label Mar 2, 2024
@hans-d hans-d closed this Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This PR has gone stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

403 AccessDenied for static website
5 participants