https://github.com/buildo/terraform-aws-website
Terraform module for creating static websites hosted on S3 and served via CloudFront
https://github.com/buildo/terraform-aws-website
Last synced: 7 months ago
JSON representation
Terraform module for creating static websites hosted on S3 and served via CloudFront
- Host: GitHub
- URL: https://github.com/buildo/terraform-aws-website
- Owner: buildo
- License: apache-2.0
- Created: 2018-01-04T10:48:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-04-22T12:28:45.000Z (over 5 years ago)
- Last Synced: 2025-01-21T03:41:34.942Z (over 1 year ago)
- Language: HCL
- Homepage: https://registry.terraform.io/modules/buildo/website/aws/
- Size: 31.3 KB
- Stars: 19
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# website Terraform module
This is a Terraform module designed to automate the deploy of a static website.
This modules creates the following resources:
- two S3 buckets, one for the content (`www.example.com`), one for redirecting from the
naked domain to www (named `example.com`)
- two CloudFront distribution, one per bucket, that also redirect from HTTP to HTTPS
- two Route53 alias records, one per CloudFront distribution
## Usage
### Prerequisites
You have to create a SSL certificate for both domains (www and naked) on AWS.
This step can't be automated, due to limitations of the AWS API.
Follow this instructions:
- Access the [Certificate Manager](https://console.aws.amazon.com/acm/) on the AWS console
- Switch to the `us-east-1` (N. Virginia) region.
- 🚨 **This is CRUCIAL, as AWS requires certificates for CloudFront to be issued in this region**
- Click on "Request a certificate"
- Enter as a primary domain name the domain you want *with www*, for example: `www.buildo.io`
- Enter the naked domain as an additional domain name, for example `buildo.io`
You should be in this situation:

**NOTE**: ⚠️ the order is important, the `www` domain must come first!
- Follow the steps for verifying the domain
### Using the module
Using the module is as simple as:
```hcl
provider "aws" {
region = "eu-west-1" // The region for the S3 buckets and the CloudFront distribution
}
module "website" {
source = "buildo/website/aws"
domain = "mysite.com" // no www here
# optional: enable health check on www.mysite.com
enable_health_check = true
health_check_alarm_sns_topics = [
""
]
}
```