@@ -9,17 +9,24 @@ locals {
9
9
10
10
resource "aws_s3_bucket" "static_upload" {
11
11
bucket_prefix = " ${ var . deployment_name } -tfn-deploy"
12
- acl = " private"
13
12
force_destroy = true
14
13
15
- # We are using versioning here to ensure that no file gets overridden at upload
16
- versioning {
17
- enabled = true
18
- }
19
-
20
14
tags = merge (var. tags , var. tags_s3_bucket )
21
15
}
22
16
17
+ resource "aws_s3_bucket_acl" "static_upload" {
18
+ bucket = aws_s3_bucket. static_upload . id
19
+ acl = " private"
20
+ }
21
+
22
+ # We are using versioning here to ensure that no file gets overridden at upload
23
+ resource "aws_s3_bucket_versioning" "static_upload" {
24
+ bucket = aws_s3_bucket. static_upload . id
25
+ versioning_configuration {
26
+ status = " Enabled"
27
+ }
28
+ }
29
+
23
30
resource "aws_s3_bucket_notification" "on_create" {
24
31
bucket = aws_s3_bucket. static_upload . id
25
32
@@ -35,23 +42,35 @@ resource "aws_s3_bucket_notification" "on_create" {
35
42
36
43
resource "aws_s3_bucket" "static_deploy" {
37
44
bucket_prefix = " ${ var . deployment_name } -tfn-static"
38
- acl = " private"
39
45
force_destroy = true
40
46
41
- lifecycle_rule {
42
- id = " Expire static assets"
43
- enabled = var. expire_static_assets >= 0 # -1 disables the cleanup
47
+ tags = merge (var. tags , var. tags_s3_bucket )
48
+ }
49
+
50
+ resource "aws_s3_bucket_acl" "static_deploy" {
51
+ bucket = aws_s3_bucket. static_deploy . id
52
+ acl = " private"
53
+ }
54
+
55
+ resource "aws_s3_bucket_lifecycle_configuration" "static_deploy" {
56
+ bucket = aws_s3_bucket. static_deploy . id
44
57
45
- tags = {
46
- " tfnextExpire" = " true"
47
- }
58
+ rule {
59
+ id = " Expire static assets"
48
60
49
61
expiration {
50
62
days = var. expire_static_assets > 0 ? var. expire_static_assets : 0
51
63
}
52
- }
53
64
54
- tags = merge (var. tags , var. tags_s3_bucket )
65
+ filter {
66
+ tag {
67
+ key = " tfnextExpire"
68
+ value = " true"
69
+ }
70
+ }
71
+
72
+ status = var. expire_static_assets >= 0 ? " Enabled" : " Disabled" # -1 disables the cleanup
73
+ }
55
74
}
56
75
57
76
# CloudFront permissions for the bucket
0 commit comments