Skip to content

Commit d30da13

Browse files
committed
Minor changes
1 parent ec8f204 commit d30da13

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,16 @@ For that reason, the module includes an aliased provider definition to create su
6060
|------|-------------|
6161
| website_cdn_root_id | CloudFront Distribution ID |
6262

63+
## Author
64+
65+
Module written by [@cloudmaniac](https://github.com/cloudmaniac). Module Support: [terraform-aws-static-website](https://github.com/cloudmaniac/terraform-aws-static-website). Contributions and comments are welcomed.
66+
6367
## Additional Resources
6468

6569
* Blog post describing the thought process behind this: [My Wordpress to Hugo Migration #2 - Hosting](https://cloudmaniac.net/wordpress-to-hugo-migration-2-hosting/)
6670

6771
## Todo
6872

6973
* Tag all ressources
74+
* Secure S3 buckets
7075
* Optional enhanced version with Lambda@Edge configuration and S3 endpoint (REST endpoint) used as the origin

main.tf

+5-3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ resource "aws_s3_bucket" "website_logs" {
8989
# Creates bucket to store the static website
9090
resource "aws_s3_bucket" "website_root" {
9191
bucket = "${var.website-domain-main}-root"
92+
acl = "public-read"
9293

9394
# Comment the following line if you are uncomfortable with Terraform destroying the bucket even if not empty
9495
force_destroy = true
@@ -116,6 +117,7 @@ resource "aws_s3_bucket" "website_root" {
116117
# Creates bucket for the website handling the redirection (if required), e.g. from https://www.example.com to https://example.com
117118
resource "aws_s3_bucket" "website_redirect" {
118119
bucket = "${var.website-domain-main}-redirect"
120+
acl = "public-read"
119121
force_destroy = true
120122

121123
logging {
@@ -149,7 +151,7 @@ resource "aws_cloudfront_distribution" "website_cdn_root" {
149151
domain_name = aws_s3_bucket.website_root.website_endpoint
150152

151153
custom_origin_config {
152-
origin_protocol_policy = "http-only"
154+
origin_protocol_policy = "http-only" # The protocol policy that you want CloudFront to use when fetching objects from the origin server (a.k.a S3 in our situation). HTTP Only is the default setting when the origin is an Amazon S3 static website hosting endpoint, because Amazon S3 doesn’t support HTTPS connections for static website hosting endpoints.
153155
http_port = 80
154156
https_port = 443
155157
origin_ssl_protocols = ["TLSv1.2", "TLSv1.1", "TLSv1"]
@@ -164,8 +166,8 @@ resource "aws_cloudfront_distribution" "website_cdn_root" {
164166
}
165167

166168
default_cache_behavior {
167-
allowed_methods = ["GET", "HEAD"]
168-
cached_methods = ["GET", "HEAD"]
169+
allowed_methods = ["GET", "HEAD", "OPTIONS"]
170+
cached_methods = ["GET", "HEAD", "OPTIONS"]
169171
target_origin_id = "origin-bucket-${aws_s3_bucket.website_root.id}"
170172
min_ttl = "0"
171173
default_ttl = "300"

0 commit comments

Comments
 (0)