-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
81 lines (66 loc) · 2.33 KB
/
main.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
resource "scaleway_object_bucket" "this" {
force_destroy = var.force_destroy
name = var.name
object_lock_enabled = var.versioning_enabled
region = var.region
project_id = var.project_id
tags = zipmap(var.tags, var.tags)
dynamic "lifecycle_rule" {
for_each = length(var.lifecycle_rules) == 0 ? [] : var.lifecycle_rules
content {
id = lifecycle_rule.value["id"]
prefix = lifecycle_rule.value["prefix"]
tags = lifecycle_rule.value["tags"]
enabled = lifecycle_rule.value["enabled"]
abort_incomplete_multipart_upload_days = lifecycle_rule.value["abort_incomplete_multipart_upload_days"]
dynamic "expiration" {
for_each = lifecycle_rule.value["expiration"] == null ? [] : [lifecycle_rule.value["expiration"]]
content {
days = expiration.value["days"]
}
}
dynamic "transition" {
for_each = lifecycle_rule.value["transition"] == null ? [] : [lifecycle_rule.value["transition"]]
content {
days = transition.value["days"]
storage_class = transition.value["storage_class"]
}
}
}
}
versioning {
enabled = var.versioning_enabled
}
}
resource "scaleway_object_bucket_acl" "this" {
acl = var.acl
bucket = scaleway_object_bucket.this.name
project_id = var.project_id
region = var.region
}
resource "scaleway_object_bucket_lock_configuration" "this" {
count = var.versioning_enabled ? 1 : 0
bucket = scaleway_object_bucket.this.name
project_id = var.project_id
rule {
default_retention {
mode = var.versioning_lock_configuration["mode"]
days = var.versioning_lock_configuration["days"]
years = var.versioning_lock_configuration["years"]
}
}
}
resource "scaleway_object_bucket_policy" "this" {
count = var.policy != null ? 1 : 0
bucket = scaleway_object_bucket.this.name
policy = jsonencode(var.policy)
project_id = var.project_id
}
resource "scaleway_object_bucket_website_configuration" "this" {
count = var.website_index != null ? 1 : 0
bucket = scaleway_object_bucket.this.name
project_id = var.project_id
index_document {
suffix = var.website_index
}
}