Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import VersionBadge from '../../../../../src/components/VersionBadge.tsx';
import { HclListItem, HclListItemDescription, HclListItemTypeDetails, HclListItemDefaultValue, HclGeneralListItem } from '../../../../../src/components/HclListItem.tsx';
import { ModuleUsage } from "../../../../../src/components/ModuleUsage";

<VersionBadge repoTitle="Static Assets Modules" version="0.17.1" lastModifiedVersion="0.17.1"/>
<VersionBadge repoTitle="Static Assets Modules" version="0.17.2" lastModifiedVersion="0.17.2"/>

# S3 CloudFront Module

<a href="https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-cloudfront" className="link-button" title="View the source code for this module in GitHub.">View Source</a>
<a href="https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-cloudfront" className="link-button" title="View the source code for this module in GitHub.">View Source</a>

<a href="https://github.com/gruntwork-io/terraform-aws-static-assets/releases/tag/v0.17.1" className="link-button" title="Release notes for only versions which impacted this module.">Release Notes</a>
<a href="https://github.com/gruntwork-io/terraform-aws-static-assets/releases/tag/v0.17.2" className="link-button" title="Release notes for only versions which impacted this module.">Release Notes</a>

This module deploys a [CloudFront](https://aws.amazon.com/cloudfront/) distribution as a Content Distribution Network
(CDN) in front of an [S3 bucket](https://aws.amazon.com/s3/). This reduces latency for your users, by caching your
static content in servers around the world. It also allows you to use SSL with the static content in an S3 bucket.

See the [s3-static-website module](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website) for how to deploy static content in an S3 bucket.
See the [s3-static-website module](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website) for how to deploy static content in an S3 bucket.

## Quick Start

* See the [cloudfront-s3-public](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/examples/cloudfront-s3-public) and
[cloudfront-s3-private](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/examples/cloudfront-s3-private) examples for working sample code.
* Check out [vars.tf](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-cloudfront/vars.tf) for all parameters you can set for this module.
* See the [cloudfront-s3-public](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/examples/cloudfront-s3-public) and
[cloudfront-s3-private](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/examples/cloudfront-s3-private) examples for working sample code.
* Check out [vars.tf](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-cloudfront/vars.tf) for all parameters you can set for this module.

## Public vs private S3 buckets

Expand Down Expand Up @@ -130,7 +130,7 @@ most use cases, but is not particularly flexible. In particular, the limitations
* Only one default cache behavior is supported
([cache behaviors](https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#cache-behavior-arguments)
is an inline block). You can control the default cache settings using a number of parameters, including
`cached_methods`, `default_ttl`, `min_ttl`, `max_ttl`, and many others (see [vars.tf](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-cloudfront/vars.tf) for the full list).
`cached_methods`, `default_ttl`, `min_ttl`, `max_ttl`, and many others (see [vars.tf](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-cloudfront/vars.tf) for the full list).

* Only two error responses are supported
([error responses](https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#custom-error-response-arguments)
Expand Down Expand Up @@ -162,7 +162,7 @@ into your own codebase, using it as a guide, and adding the tweaks you need.

module "s_3_cloudfront" {

source = "git::git@github.com:gruntwork-io/terraform-aws-static-assets.git//modules/s3-cloudfront?ref=v0.17.1"
source = "git::git@github.com:gruntwork-io/terraform-aws-static-assets.git//modules/s3-cloudfront?ref=v0.17.2"

# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
Expand Down Expand Up @@ -455,7 +455,7 @@ module "s_3_cloudfront" {
# ------------------------------------------------------------------------------------------------------

terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-static-assets.git//modules/s3-cloudfront?ref=v0.17.1"
source = "git::git@github.com:gruntwork-io/terraform-aws-static-assets.git//modules/s3-cloudfront?ref=v0.17.2"
}

inputs = {
Expand Down Expand Up @@ -1413,11 +1413,11 @@ If you have specified whitelist in <a href="#forward_cookies"><code>forward_cook
<!-- ##DOCS-SOURCER-START
{
"originalSources": [
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-cloudfront/readme.md",
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-cloudfront/variables.tf",
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-cloudfront/outputs.tf"
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-cloudfront/readme.md",
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-cloudfront/variables.tf",
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-cloudfront/outputs.tf"
],
"sourcePlugin": "module-catalog-api",
"hash": "7acd49aeb1b1157e6ceada26b7d8f036"
"hash": "82e32b4a9a643b301d8c0955b949f13d"
}
##DOCS-SOURCER-END -->
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import VersionBadge from '../../../../../src/components/VersionBadge.tsx';
import { HclListItem, HclListItemDescription, HclListItemTypeDetails, HclListItemDefaultValue, HclGeneralListItem } from '../../../../../src/components/HclListItem.tsx';
import { ModuleUsage } from "../../../../../src/components/ModuleUsage";

<VersionBadge repoTitle="Static Assets Modules" version="0.17.1" lastModifiedVersion="0.17.1"/>
<VersionBadge repoTitle="Static Assets Modules" version="0.17.2" lastModifiedVersion="0.17.2"/>

# S3 Static Website

<a href="https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website" className="link-button" title="View the source code for this module in GitHub.">View Source</a>
<a href="https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website" className="link-button" title="View the source code for this module in GitHub.">View Source</a>

<a href="https://github.com/gruntwork-io/terraform-aws-static-assets/releases/tag/v0.17.1" className="link-button" title="Release notes for only versions which impacted this module.">Release Notes</a>
<a href="https://github.com/gruntwork-io/terraform-aws-static-assets/releases/tag/v0.17.2" className="link-button" title="Release notes for only versions which impacted this module.">Release Notes</a>

This module creates an AWS S3 bucket that can be used to host a static website. That is, the website can contain static HTML, CSS, JS, and images.

Expand All @@ -29,39 +29,39 @@ This module creates an AWS S3 bucket that can be used to host a static website.

* Optionally configure a custom domain name for the website.

* Optionally deploy a CDN in front of S3 using the [s3-cloudfront module](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-cloudfront).
* Optionally deploy a CDN in front of S3 using the [s3-cloudfront module](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-cloudfront).

## Learn

The reason to serve static content from S3 rather than from your own app server is that it can significantly reduce the load on your server, allowing it to solely focus on serving dynamic data. This will save you money and make your website run faster. For even bigger improvements in performance, consider deploying a CloudFront Content Distribution Network (CDN) in front of the S3 bucket using the s3-cloudfront module.

### Core concepts

* [Quick Start](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website/core-concepts.md#quick-start)
* [Quick Start](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website/core-concepts.md#quick-start)

* [How to test the website](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website/core-concepts.md#how-to-test-the-website)
* [How to test the website](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website/core-concepts.md#how-to-test-the-website)

* [How to configure HTTPS (SSL) or a CDN?](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website/core-concepts.md#how-to-configure-http)
* [How to configure HTTPS (SSL) or a CDN?](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website/core-concepts.md#how-to-configure-http)

* [How to handle www + root domains](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website/core-concepts.md#how-to-handle)
* [How to handle www + root domains](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website/core-concepts.md#how-to-handle)

* [How do I configure Cross Origin Resource Sharing (CORS)?](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website/core-concepts.md#how-do-i-configure-cross-origin-resource-sharing-cors)
* [How do I configure Cross Origin Resource Sharing (CORS)?](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website/core-concepts.md#how-do-i-configure-cross-origin-resource-sharing-cors)

### Repo organization

* [modules](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules): The main implementation code for this repo, broken down into multiple standalone, orthogonal submodules.
* [modules](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules): The main implementation code for this repo, broken down into multiple standalone, orthogonal submodules.

* [examples](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/examples): This folder contains working examples of how to use the submodules.
* [examples](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/examples): This folder contains working examples of how to use the submodules.

* [test](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/test): Automated tests for the modules and examples.
* [test](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/test): Automated tests for the modules and examples.

## Deploy

### Non-production deployment (quick start for learning)

If you just want to try this repo out for experimenting and learning, check out the following resources:

* [Examples folder](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/examples): The `examples` folder contains sample code optimized for learning, experimenting, and testing (but not production usage).
* [Examples folder](https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/examples): The `examples` folder contains sample code optimized for learning, experimenting, and testing (but not production usage).

### Production deployment

Expand All @@ -82,7 +82,7 @@ If you want to deploy this repo in production, check out the following resources

module "s_3_static_website" {

source = "git::git@github.com:gruntwork-io/terraform-aws-static-assets.git//modules/s3-static-website?ref=v0.17.1"
source = "git::git@github.com:gruntwork-io/terraform-aws-static-assets.git//modules/s3-static-website?ref=v0.17.2"

# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
Expand Down Expand Up @@ -267,7 +267,7 @@ module "s_3_static_website" {
# ------------------------------------------------------------------------------------------------------

terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-static-assets.git//modules/s3-static-website?ref=v0.17.1"
source = "git::git@github.com:gruntwork-io/terraform-aws-static-assets.git//modules/s3-static-website?ref=v0.17.2"
}

inputs = {
Expand Down Expand Up @@ -860,11 +860,11 @@ A value that can be used to chain resources to depend on the website bucket bein
<!-- ##DOCS-SOURCER-START
{
"originalSources": [
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website/readme.adoc",
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website/variables.tf",
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.1/modules/s3-static-website/outputs.tf"
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website/readme.adoc",
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website/variables.tf",
"https://github.com/gruntwork-io/terraform-aws-static-assets/tree/v0.17.2/modules/s3-static-website/outputs.tf"
],
"sourcePlugin": "module-catalog-api",
"hash": "a52aa3205cc61bebecdc32aa591408b8"
"hash": "bed3c746c7d7cad8b06143198303361c"
}
##DOCS-SOURCER-END -->