Browse the Repo

file-type-icon.circleci
file-type-iconexamples
file-type-iconbin
file-type-iconcloudfront-s3-private-origin-group
file-type-iconcloudfront-s3-private
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvars.tf
file-type-iconcloudfront-s3-public-origin-group
file-type-iconcloudfront-s3-public
file-type-iconexample-website
file-type-icons3-static-website
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.md

Browse the Repo

file-type-icon.circleci
file-type-iconexamples
file-type-iconbin
file-type-iconcloudfront-s3-private-origin-group
file-type-iconcloudfront-s3-private
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvars.tf
file-type-iconcloudfront-s3-public-origin-group
file-type-iconcloudfront-s3-public
file-type-iconexample-website
file-type-icons3-static-website
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.md
S3

S3

Deploy your static content and static websites on S3. Supports bucket versioning, redirects, and access logging.

Code Preview

Preview the Code

mobile file icon

README.md

down

CloudFront + S3 private bucket example

This folder shows an example of how to use the s3-cloudfront and s3-static-website modules to deploy a CloudFront distribution as a CDN in front of a private S3 bucket. Make sure to read the Public vs private S3 buckets documentation to understand the difference between this example and the cloudfront-s3-public example.

NOTE: For some reason, it appears that CloudFront only works with private S3 bucket in us-east1. In all other regions, you get 403: Access Denied errors. We are still investigating why, but for the time being, the solution is to deploy your static website in us-east-1 and things will work fine.

Quick start

To try these templates out you must have Terraform installed:

  1. Open vars.tf, set the environment variables specified at the top of the file, and fill in any other variables that don't have a default.
  2. Run terraform get.
  3. Run terraform plan.
  4. If the plan looks good, run terraform apply.

When the apply command finishes, this module will output the domain name you can use to test the website in your browser.

Note that a CloudFront distribution can take a LONG time to deploy (i.e. sometimes as much as 15 - 30 minutes!), so before testing the URL, head over to the CloudFront distributions page and wait for the "Status" of your distribution to show up as "Deployed".

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?