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

S3 website distributed by CloudFront does not redirect subdir/ to subdir/index.html #107

Closed
jmcgeheeiv opened this issue Oct 15, 2020 · 2 comments
Labels
bug 🐛 An issue with the system

Comments

@jmcgeheeiv
Copy link
Contributor

jmcgeheeiv commented Oct 15, 2020

Description

I took advantage of the new website_enabled feature to create a S3 website distributed by CloudFront.

I can access the contact/index.html page directly from the S3 website without "index.html":

http://namespace-environment-name-attribute.s3-website-us-east-1.amazonaws.com/contact/

This S3 bucket is distributed by CloudFront at stage.example.com. Here, the page works only when I specify "index.html":

https://stage.example.com/contact/                     403 error--access denied
https://stage.example.com/contact/index.html     works

My main motivation in using the S3 website was to get the index.html redirection, and avoid the Lambda@Edge redirection approach.

Expected Behavior

I want CloudFront to forward the request for https://stage.example.com/contact/ to the S3 website, which would respond with https://stage.example.com/contact/index.html. This is in fact possible. I have demonstrated it with another Terraform configuration.

Do you know how to get this to work? AWS did not know. I ask you because this module suggests that you have experience with using an S3 website as a CloudFront origin.

References

I am using my enhanced version of this module as described in PR #105. I believe that the redirection described here is orthogonal to PR #105 because:

  • An S3 website is a custom origin, which is supported as-is in version 0.35.0
  • The problem manifests whether or not the S3 website is public

Steps to Reproduce

This issue is really asking you to recall your past experience--"When you used an S3 website origin with CloudFront, how did you get this to work?" Still, here are the steps to reproduce the behavior:

  1. Create the resources with module terraform-aws-cloudfront-s3-cdn
  2. Upload to the S3 origin file contact/index.html
  3. Access https://stage.example.com/contact/
  4. Get 403 error, access denied

Screenshots

If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • Version 0.35.0
@jmcgeheeiv jmcgeheeiv added the bug 🐛 An issue with the system label Oct 15, 2020
@jmcgeheeiv
Copy link
Contributor Author

The URL that clients use to access the website must be specified using variable alias. I am inclined to recommend that alias be changed to a required variable.

@jmcgeheeiv
Copy link
Contributor Author

The solution to this problem is implemented in #105.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

1 participant