-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommon.tf
204 lines (196 loc) · 5.11 KB
/
common.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# ------------------------------------------------------------------------------
# Resource Labels
# ------------------------------------------------------------------------------
module "labels" {
source = "[email protected]:3scale-ops/tf-aws-label.git?ref=tags/0.1.2"
project = var.project
environment = var.environment
workload = var.workload
type = "s3"
tf_config = var.tf_config
}
locals {
# ------------------------------------------------------------------------------
# Master Bucket Id
# ------------------------------------------------------------------------------
master_bucket_id = format("%s-%s-%s-%s",
var.bucket_name_prefix, var.environment, var.project, var.workload,
)
# ------------------------------------------------------------------------------
# Replica Bucket Id
# ------------------------------------------------------------------------------
replica_bucket_id = format("%s-replica", local.master_bucket_id)
# ----------------------------------------------------------------------------
# S3 Lifecycle Rules for both master and replica bucket
# ----------------------------------------------------------------------------
common_lifecycle_rules = [
{
# Default rule
# For objects when no other policy takes precedence
# * https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-configuration-examples.html#lifecycle-config-conceptual-ex5
# - Removes versions after 15 days
# - Moves to Glacier after 360 days
# - Never Expire
id = "No expiration (Default)"
enabled = true
transition = [{
days = 360
storage_class = "GLACIER"
}]
noncurrent_version_expiration = {
days = 15
}
expiration = {
expired_object_delete_marker = true
}
abort_incomplete_multipart_upload_days = 3
},
{
# 1 year Glacier rule
# For objects tagged with `Retention: Long-term` and `Archive: Glacier`
# - Removes versions after 24 hours
# - Moves to Glacier after 48 hours
# - Expires after 1 year
id = "1 year Glacier"
enabled = true
tags = {
Retention = "1y",
Archive = "Glacier"
}
transition = [
{
days = 2
storage_class = "GLACIER"
}]
expiration = {
days = 360
}
noncurrent_version_expiration = {
days = 1
}
},
{
# 1 year rule
# For objects tagged with `Retention: 1y`
# - Removes versions after 24 hours
# - Expires after 1 year
id = "1 year"
enabled = true
tags = {
Retention = "1y"
}
expiration = {
days = 360
}
noncurrent_version_expiration = {
days = 1
}
},
{
# 90d Glacier expiration rule
# For objects tagged with `Retention: 90d` and `Archive: Glacier`
# - Removes versions after 7 days
# - Moves to Glacier after 7 days
# - Expires after 90 days in Glacier (97 since creation)
id = "90 day Glacier"
enabled = true
tags = {
Retention = "90d"
Archive = "Glacier"
}
transition = [
{
days = 7
storage_class = "GLACIER"
}]
noncurrent_version_expiration = {
days = 7
}
expiration = {
days = 97
}
},
{
# 90d expiration rule
# For objects tagged with `Retention: 90d`
# - Removes versions after 7 days
# - Expires after 97 days (to match 90 day glacier policy)
id = "90 day"
enabled = true
tags = {
Retention = "90d"
}
noncurrent_version_expiration = {
days = 7
}
expiration = {
days = 97
}
},
{
# 30d expiration rule
# For objects tagged with `Retention: 30d`
# - Removes versions after 7 days
# - Expires after 30 days
id = "30 day"
enabled = true
tags = {
Retention = "30d"
}
noncurrent_version_expiration = {
days = 7
}
expiration = {
days = 30
}
},
{
# 7d expiration rule
# For objects tagged with `Retention: 7d`
# - Expires after 7 days
id = "7d day"
enabled = true
tags = {
Retention = "7d"
}
noncurrent_version_expiration = {
days = 3
}
expiration = {
days = 7
}
},
{
# 3d expiration rule
# For objects tagged with `Retention: 3d`
# - Expires after 3 days
id = "3d day"
enabled = true
tags = {
Retention = "3d"
}
noncurrent_version_expiration = {
days = 1
}
expiration = {
days = 3
}
},
{
# 24h expiration rule
# For objects tagged with `Retention: 24h`
# - Expires after 24 hours
id = "24 hours"
enabled = true
tags = {
Retention = "24h"
}
noncurrent_version_expiration = {
days = 1
}
expiration = {
days = 1
}
}
]
}