Skip to content

Commit 7fe747a

Browse files
committed
Updated s3 resource
1 parent b2d606e commit 7fe747a

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# terraform-aws-s3-static-website
2+
23
Used to publish static website files to an S3 bucket with proper MIME type
34

45
## Example
56

67
``` Terraform
78
module "s3-static-website" {
89
source = "Lupus-Metallum/s3-static-website/aws"
9-
version = "1.0.6"
10+
version = "1.1.0"
1011
11-
bucket_id = aws_s3_bucket.example.id
12-
file_path = "${path.module}/src/my-website-files/" # Where your index.html and TLD web content lives
13-
acl = "public-read"
14-
storage_class = "STANDARD"
15-
cache_control = "max-age=31536000"
12+
bucket_id = aws_s3_bucket.example.id
13+
file_path = "${path.module}/src/my-website-files/" # Where your index.html and TLD web content lives
14+
acl = "public-read"
15+
storage_class = "STANDARD"
16+
cache_control = "max-age=31536000"
17+
content_language = "en-US"
1618
}
1719
```

main.tf

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
resource "aws_s3_bucket_object" "this" {
1+
resource "aws_s3_object" "this" {
22
for_each = fileset(var.file_path, "**")
33

4-
content_type = lookup(jsondecode(file("${path.module}/src/mime.json")), regex("\\.[^.]+$", each.value), null)
5-
cache_control = var.cache_control
6-
acl = var.acl
7-
bucket = var.bucket_id
8-
storage_class = var.storage_class
9-
key = each.value
10-
source = "${var.file_path}/${each.value}"
11-
etag = filemd5("${var.file_path}/${each.value}")
4+
content_type = lookup(jsondecode(file("${path.module}/src/mime.json")), regex("\\.[^.]+$", each.value), null)
5+
content_language = var.content_language
6+
cache_control = var.cache_control
7+
acl = var.acl
8+
bucket = var.bucket_id
9+
storage_class = var.storage_class
10+
key = each.value
11+
source = "${var.file_path}/${each.value}"
12+
etag = filemd5("${var.file_path}/${each.value}")
1213
}

variables.tf

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
variable "bucket_id" {
2-
type = string
2+
type = string
33
description = "The bucket id to use as the destination for the static website"
44
}
55

66
variable "file_path" {
7-
type = string
7+
type = string
88
description = "The base filepath that contains the files to publish, you may need path.module/my/src/dir"
99
}
1010

1111
variable "acl" {
12-
type = string
13-
default = "public-read"
12+
type = string
13+
default = "public-read"
1414
description = "The object acl to use for this site, defaults to public-read"
1515
}
1616

1717
variable "storage_class" {
18-
type = string
19-
default = "STANDARD"
18+
type = string
19+
default = "STANDARD"
2020
description = "The object storage class to use for this site, defaults to STANDARD"
2121
}
2222

2323
variable "cache_control" {
24-
type = string
25-
default = "max-age=1440"
24+
type = string
25+
default = "max-age=1440"
2626
description = "The header to use for cache control"
27-
}
27+
}
28+
29+
variable "content_language" {
30+
type = string
31+
default = "en-US"
32+
description = "en-US or en-GB for language header?"
33+
}

0 commit comments

Comments
 (0)