Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/techjacker/terraform-aws-s3website
Terraform modules to create a static website hosted on AWS S3 and set up MX records
https://github.com/techjacker/terraform-aws-s3website
mx s3-website terraform terraform-modules
Last synced: 9 days ago
JSON representation
Terraform modules to create a static website hosted on AWS S3 and set up MX records
- Host: GitHub
- URL: https://github.com/techjacker/terraform-aws-s3website
- Owner: techjacker
- License: bsd-3-clause
- Created: 2017-04-11T21:37:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-02T20:53:34.000Z (over 2 years ago)
- Last Synced: 2024-04-11T20:36:53.088Z (7 months ago)
- Topics: mx, s3-website, terraform, terraform-modules
- Language: HCL
- Homepage:
- Size: 39.1 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Terraform S3 Website & MX
Provisions S3 website and MX records.## Usage Guide
### 1. Update `terraform.tfvars` with domain
```HCL
domain = "example.com"
```
### 2. Update `backend.tf`
Change key to `/terraform.tfstate`, eg:
```HCL
key = "terraform-aws-s3website/terraform.tfstate"
```
### 3. Push to github main branch to trigger terraform apply
See `.github/workflows/terraform.yml`### 4. Plug in Nameservers to domain registrar
Go to namecheap.com or similar and plug these in to your domain.
```
$ terraform output
```
### 5. Update `terraform.tfvars` to enable S3 website provisioning
```HCL
enable_website = true
```
### 6. Push to github main branch to trigger terraform apply-------------------------------------------
## Local Dev Setup
### 1. Install Dependencies
Install and init [pre-commit](https://pre-commit.com/) and [tflint](https://github.com/terraform-linters/tflint).
```
$ pip install pre-commit
$ brew install tflint
```
### 2. Initialise pre-commit hooks and tflint
```
$ tflint --init
$ pre-commit install
```
### 3. Update Lockfiles
Add checksums for all platforms to [terraform lock files](https://www.terraform.io/language/files/dependency-lock#new-provider-package-checksums)
```
$ make lockfiles
```
### 4. Run lint on all files
```
$ pre-commit run --all-files
```-------------------------------------------
### Test
```Shell
$ curl -sI http://example.com | grep -E '(301|Server|Location|X-Cache|HTTP)'
HTTP/1.1 301 Moved Permanently
Server: CloudFront
Location: https://example.com/
X-Cache: Redirect from cloudfront$ curl -sI https://example.com | grep -E '(X-Cache|HTTP)'
HTTP/1.1 200 OK
X-Cache: Hit from cloudfront$ curl -sI http://www.example.com | grep -E '(301|Server|Location|X-Cache|HTTP)'
HTTP/1.1 301 Moved Permanently
Server: CloudFront
Location: https://www.example.com/
X-Cache: Redirect from cloudfront$ curl -sI https://www.example.com | grep -E '(301|Server|Location|HTTP)'
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
Server: AmazonS3
```