Giter VIP home page Giter VIP logo

https-static-site-cloudformation's People

Contributors

watsonarw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

https-static-site-cloudformation's Issues

Serve default index.html file for folders

There is a current limitation with this template where all paths must be referenced by the full file name, and not the directory name.

e.g a site with the path /foowhere /foo/index.html exists, does not serve the index.htmlfile and instead responds with the error file.

This is due to a limitation with Cloudfront, and the workaround is to use the bucket's web facing url, and point Cloudfront at the web origin instead of as an S3 origin. See this stackoverflow question.

Amazon's recommended fix is to use Lambda@Edge to rewrite the path when it gets the file from S3.

The response should be cached by Cloudfront, and only invoke the lambda on cache misses.

Acceptance Criteria

  1. Directories serve index.html with /
    Given I have a directory foo with an index.html file
    When I try to access the directory example.com/foo/ (with trailing /) via cloudfront
    Then I am served the foo/index.htmlfile

  2. Directories serve index.html without /
    Given I have a directory foo with an index.html file
    When I try to access the directory example.com/foo (without trailing /) via cloudfront
    Then I am served the foo/index.htmlfile

  3. Doesn't work without index.html
    Given I have a directory foo without an index.html file
    When I try to access the directory example.com/foo (without trailing /) via cloudfront
    Then I am served the error page

  4. Named files don't work as directories
    Given I have a file foo.html
    When I try to access the example.com/foo via cloudfront
    Then I am served the error page

  5. Named files don't work as directories with /
    Given I have a file foo.html
    When I try to access the example.com/foo/ via cloudfront
    Then I am served the error page

  6. Named files continue to work as files
    Given I have a file foo.html
    When I try to access the example.com/foo.html via cloudfront
    Then I am served the /foo.html

Cloudfront -> s3 pointer

Hey, this thing is awesome. I have a production site running based off of this template, and the only hiccup I encountered is that the cloudfront distribution generated points directly to the s3 bucket URL (http://bucketname.s3.amazonaws.com), not the bucket's 'web facing' url (e.g. http://bucketname.com.s3-website-us-east-1.amazonaws.com). For me, this allowed the home page to work, but all subpages were broken until I updated the origin URL.

I also had to add the naked domain to the distributions 'alternate domain names' to get it to redirect to www.

One other feature suggestion -- it might be useful to allow the user to specify a different bucket name than the URL. This was a pain point for me because I had the website hosted on another AWS account (just using s3) where the bucket name was the domain, and since you can't use an existing bucket name, I had to shut that one down first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.