Skip to content

Commit 1c8a14c

Browse files
committed
Ready for Terraform Registry
1 parent 068c550 commit 1c8a14c

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,55 @@ Terraform module which provision required AWS resources to host a performant and
66

77
## Features
88

9-
This Terraform module will create the following AWS resources:
9+
This Terraform module creates the following AWS resources:
1010

11-
* **AWS Certificate Manager** to create a wildcard certificate for your domain.
11+
* **AWS Certificate Manager**: wildcard certificate for your domain.
1212
* **S3**
13-
* One bucket to store static public files.
14-
* One bucket to redirect a different subdomain to the main domain.
15-
* One bucket to store access logs.
13+
* Bucket #1: to store logs.
14+
* Bucket #2: to store the content (`example.com`).
15+
* Bucket #3: to redirect a different subdomain to the main domain (e.g., `www.example.com` redirected to `example.com`).
1616
* **CloudFront**
17-
* One distribution to frontend the website.
18-
* One distribution to frontend the sub-domain that will be redirect to the main domain.
17+
* Distribution #1: to frontend the website.
18+
* Distribution #2: to frontend the subdomain that will be redirect to the main domain.
1919
* **Lambda@Edge** (triggered by the CloudFront Distribution) to re-write requests so that CloudFront requests a default index object (e.g., index.html) for subfolders.
20-
* **Route53** record sets pointing to the CloudFront distributions.
20+
* **Route53** record sets pointing to the two CloudFront distributions.
2121

2222
## Requirements
2323

2424
* This module is meant for use with [Terraform](https://www.terraform.io/downloads.html) 0.12+. It has not been tested with previous versions of Terraform.
25-
* An AWS account and your credentials (`aws_access_key_id` and `aws_secret_access_key`) stored in a [credential file](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).
25+
* An AWS account and your credentials (`aws_access_key_id` and `aws_secret_access_key`) configured. There are several ways to do this (environment variables, shared credentials file, etc.): my preference is to store them in a [credential file](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html). More information in the [AWS Provider](https://www.terraform.io/docs/providers/aws/index.html) documentation.
2626
* Your domain already configured as a hosted zone on Route53.
2727

2828
## Usage
2929

3030
```HCL
31+
provider "aws" {
32+
version = "~> 2.0"
33+
region = "eu-west-3"
34+
shared_credentials_file = "~/.aws/credentials"
35+
}
36+
3137
module "aws_static_website" {
3238
source = "cloudmaniac/static-website/aws"
3339
34-
aws-region-default = "eu-west-3"
35-
website-domain-main = "cluster.net"
36-
website-domain-redirect = "www.cluster.net"
40+
website-domain-main = "example.com"
41+
website-domain-redirect = "www.example.com"
3742
}
3843
```
3944

45+
Although AWS services are available in many locations, some of them require the `us-east-1` (N. Virginia) region to be configured:
46+
47+
* To use an ACM certificate with Amazon CloudFront, you must request or import the certificate in the US East (N. Virginia) region. ACM certificates in this region that are associated with a CloudFront distribution are distributed to all the geographic locations configured for that distribution.
48+
* Lambda@Edge functions can now be authored in US East (N. Virginia), and will be replicated globally for invocation in response to CloudFront events.
49+
50+
For those reasons, the module includes an aliased provider definition to create those resources in the `us-east-1` region. Remaining resources from the module will inherit default (un-aliased) provider configurations from the parent.
51+
4052
## Inputs
4153

4254
| Name | Description | Type | Default | Required |
4355
|------|-------------|:----:|:-------:|:--------:|
44-
| aws-region-default | Default region | string | us-east-1 | no |
4556
| website-domain-main | Domain for the website (e.g., `example.com`) | string | - | yes |
46-
| website-domain-redirect | Domain to redirect to the main website (e.g., `www.example.com`) | string | - | yes |
57+
| website-domain-redirect | Alternate subdomain to redirect to the main website (e.g., `www.example.com`) | string | - | yes |
4758

4859
## Outputs
4960

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Providers definition
2-
# Default provider will be inherited from the enclosing configuration.
2+
# Default provider will be inherited from the enclosing configuration
33

44
# The provider below is required to handle ACM and Lambda in a CloudFront context
55
provider "aws" {

0 commit comments

Comments
 (0)