-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
# terraform-aws-s3-static-website | ||
|
||
Used to publish static website files to an S3 bucket with proper MIME type | ||
|
||
## Example | ||
|
||
``` Terraform | ||
module "s3-static-website" { | ||
source = "Lupus-Metallum/s3-static-website/aws" | ||
version = "1.0.6" | ||
version = "1.1.0" | ||
bucket_id = aws_s3_bucket.example.id | ||
file_path = "${path.module}/src/my-website-files/" # Where your index.html and TLD web content lives | ||
acl = "public-read" | ||
storage_class = "STANDARD" | ||
cache_control = "max-age=31536000" | ||
bucket_id = aws_s3_bucket.example.id | ||
file_path = "${path.module}/src/my-website-files/" # Where your index.html and TLD web content lives | ||
acl = "public-read" | ||
storage_class = "STANDARD" | ||
cache_control = "max-age=31536000" | ||
content_language = "en-US" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
resource "aws_s3_bucket_object" "this" { | ||
resource "aws_s3_object" "this" { | ||
for_each = fileset(var.file_path, "**") | ||
|
||
content_type = lookup(jsondecode(file("${path.module}/src/mime.json")), regex("\\.[^.]+$", each.value), null) | ||
cache_control = var.cache_control | ||
acl = var.acl | ||
bucket = var.bucket_id | ||
storage_class = var.storage_class | ||
key = each.value | ||
source = "${var.file_path}/${each.value}" | ||
etag = filemd5("${var.file_path}/${each.value}") | ||
content_type = lookup(jsondecode(file("${path.module}/src/mime.json")), regex("\\.[^.]+$", each.value), null) | ||
content_language = var.content_language | ||
cache_control = var.cache_control | ||
acl = var.acl | ||
bucket = var.bucket_id | ||
storage_class = var.storage_class | ||
key = each.value | ||
source = "${var.file_path}/${each.value}" | ||
etag = filemd5("${var.file_path}/${each.value}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
variable "bucket_id" { | ||
type = string | ||
type = string | ||
description = "The bucket id to use as the destination for the static website" | ||
} | ||
|
||
variable "file_path" { | ||
type = string | ||
type = string | ||
description = "The base filepath that contains the files to publish, you may need path.module/my/src/dir" | ||
} | ||
|
||
variable "acl" { | ||
type = string | ||
default = "public-read" | ||
type = string | ||
default = "public-read" | ||
description = "The object acl to use for this site, defaults to public-read" | ||
} | ||
|
||
variable "storage_class" { | ||
type = string | ||
default = "STANDARD" | ||
type = string | ||
default = "STANDARD" | ||
description = "The object storage class to use for this site, defaults to STANDARD" | ||
} | ||
|
||
variable "cache_control" { | ||
type = string | ||
default = "max-age=1440" | ||
type = string | ||
default = "max-age=1440" | ||
description = "The header to use for cache control" | ||
} | ||
} | ||
|
||
variable "content_language" { | ||
type = string | ||
default = "en-US" | ||
description = "en-US or en-GB for language header?" | ||
} |