-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy paths3.tf
38 lines (31 loc) · 1.01 KB
/
s3.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
resource "aws_s3_bucket" "my_bucket" {
bucket = var.s3_website_bucket
acl = "public-read"
website {
index_document = "index.html"
error_document = "error.html"
}
}
module "dir" {
source = "hashicorp/dir/template"
version = "1.0.2"
base_dir = "${path.module}/src"
template_vars = {
# Pass in any values that you wish to use in your templates.
website_title = "My Cool 😎 Website"
}
}
resource "aws_s3_bucket_object" "static_files" {
for_each = module.dir.files
bucket = aws_s3_bucket.my_bucket.id
key = each.key
content_type = each.value.content_type
# The template_files module guarantees that only one of these two attributes
# will be set for each file, depending on whether it is an in-memory template
# rendering result or a static file on disk.
source = each.value.source_path
content = each.value.content
# Unless the bucket has encryption enabled, the ETag of each object is an
# MD5 hash of that object.
etag = each.value.digests.md5
}