Terraform for launching a static website on S3
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Create hosted zone Mar 7, 2018
LICENSE Initial commit Mar 7, 2018
README.md Add note about name servers Mar 9, 2018
buckets.tf Revert to custom origin config Mar 18, 2018
cloudfront.tf Revert to custom origin config Mar 18, 2018
index.html Add S3 bucket configuration Mar 9, 2018
outputs.tf Create hosted zone Mar 7, 2018
ssl-certificate.tf Adjust formatting Mar 16, 2018
variables.tf Adjust formatting Mar 16, 2018
zone.tf Adjust formatting Mar 16, 2018

README.md

Terraform for S3 Static Website

This is a set of Terraform files to set up a static website in AWS. It makes use of the following resources:

  • S3
  • Route53
  • CloudFront
  • Certificate Manager

The end result is a website that supports:

  • a primary and secondary domain (typically apex and www domains)
  • HTTPS
  • redirect from secondary to primary

Usage

  1. Install Terraform
  2. Configure your AWS profile
  3. git clone git@github.com:alimac/terraform-s3-static-website.git
  4. cd terraform-s3-static-website
  5. terraform apply

You will be prompted to provide values for primary and secondary domain.

In addition to typing values at the prompt, you can create a terraform.tfvars file:

primary_domain = "example.com"
secondary_domain = "www.example.com"

If AWS is not your domain registrar, you will need to set your domain's name servers to AWS name servers associated with your hosted zone. Terraform will output those automatically:

Outputs:

name_servers = [
    ns-1500.awsdns-59.org,
    ns-1595.awsdns-07.co.uk,
    ns-619.awsdns-13.net,
    ns-63.awsdns-07.com
]