From 7fe747aa2cbdedd704f71ea0c291ddb051090e21 Mon Sep 17 00:00:00 2001 From: Nick Adams Date: Mon, 16 May 2022 17:49:02 -0500 Subject: [PATCH] Updated s3 resource --- README.md | 14 ++++++++------ main.tf | 19 ++++++++++--------- variables.tf | 24 +++++++++++++++--------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e1e48ae..6dff9b6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # terraform-aws-s3-static-website + Used to publish static website files to an S3 bucket with proper MIME type ## Example @@ -6,12 +7,13 @@ Used to publish static website files to an S3 bucket with proper MIME type ``` 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" } ``` diff --git a/main.tf b/main.tf index 33d3137..e3ca71a 100644 --- a/main.tf +++ b/main.tf @@ -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}") } \ No newline at end of file diff --git a/variables.tf b/variables.tf index 9efcbb9..5259e57 100644 --- a/variables.tf +++ b/variables.tf @@ -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" -} \ No newline at end of file +} + +variable "content_language" { + type = string + default = "en-US" + description = "en-US or en-GB for language header?" +}