GithubHelp home page GithubHelp logo

terraform-modules's Introduction

Terraform Modules

A collection of potentially reusable Terraform modules for common AWS patterns.

Index

AWS S3 Static Websites

The s3-website-* modules provide everything required to configure a cost-efficent static website with AWS S3. You can combine these modules for a complete static website hosting solution, including CDN with and DNS, or you can use the modules ร  la carte if you are already using another provider for CDN and DNS, such as CloudFlare.

Usage

See examples/s3-website/main.tf for a complete example.

s3-website-bucket module

Creates and configures an S3 bucket to host a static website. As part of the configuration, the s3-website-bucket module creates a redirect rule that will 301 redirect requests from /_s3_website_redirect/<path> to https://<primary_domain>/<path>. This is used by the s3-website-cloudfront module in order to setup redirects from multiple domains (such as .net, .org, and www.) to the canonical domain without having to create a separate bucket for each domain.

Variables

name type description required default
primary_domain string primary (or canonical) domain of your website yes
index_document string the default page returned when the request path ends with / no index.html
error_document string a custom error page to show instead of the AWS S3 default error page no index.html

Outputs

name type description
bucket_domain string the S3 endpoint for your bucket website
website_url string the full URL of your S3 bucket website

s3-website-cloudfront module

Creates a CloudFront distributions configured to use the S3 bucket website identified by the bucket_domain variable as its origin.

Variables

name type description required default
bucket_domain string the S3 endpoint of your bucket website, this is the same value as the s3-website-bucket module's bucket_domain output yes
alias_domains list a list of custom domains that yes
https_mode string the viewer protocol policy for this cloudfront distribution no allow-all
redirect_to_primary bool whether the alias_domains should redirect to the primary (canonical) domain* no false

*When redirect_to_primary is set to true, the distribution will use /_s3_website_redirect as the origin path. If used in combination with the s3-website-bucket module, this will result in any request to any of the alias domains referenced in this distribution to redirect to the primary_domain configured for the S3 bucket website.

Outputs

name type description
domain_name string the cloudfront distribution endpoint
hosted_zone_id string the route53 zone ID for the cloudfront distribution

s3-website-route53 module

Creates the DNS configuration required to use custom domains for your cloudfront distributions by creating route53 zones and record sets. Assuming you have created two cloudfront distributions and s3 website redirect rules using the s3-website-cloudfront and s3-website-bucket modules as shown in examples/s3-website/main.tf, this module will set up the DNS records to point to the appropriate CloudFront distribution (primary or redirect) for the given domains. If you are already hosting DNS for your site elsewhere, or even if you already have a hosted zone and record sets configured with route53, this module will likely not be useful to you. If however, you are setting up a new site from scratch, this module can save you the effort of configuring DNS manually.

NOTE: this module does not register a domain or configure your nameservers. You will need to register the domain yourself using any domain registrar. You will also need to use your registrar's interface to update the nameservers for your domain to match the nameservers output of this module.

Variables

name type description required default
zones list a list of domains to create route53 hosted zones for yes
primary_domain string the primary domain of your website yes
primary_distribution_domain string the cloudfront distribution domain of your primary distribution yes
primary_distribution_zone_id string the cloudfront distribution hosted zone id of your primary distribution yes
redirect_distribution_domain string the cloudfront distribution domain of your redirect distribution yes
redirect_distribution_zone_id string the cloudfront distribution hosted zone id of your redirect distribution yes

Outputs

name type description
nameservers list a list of nameservers to configure in your custom domains' whois records

terraform-modules's People

Contributors

jbgo avatar

Watchers

 avatar  avatar

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.