-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy paths3.tf-disabled
96 lines (91 loc) · 1.98 KB
/
s3.tf-disabled
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
data "aws_iam_policy_document" "s3_policy_config" {
count = var.enable_config_baseline ? 1 : 0
statement {
sid = "ConfigLogs"
effect = "Allow"
principals {
type = "Service"
identifiers = ["config.amazonaws.com"]
}
actions = [
"s3:PutObject"
]
resources = [
"arn:aws:s3:::${local.config_s3_bucket_name}/*"
]
}
statement {
sid = "OrgAccounts"
effect = "Allow"
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
}
actions = [
"s3:PutObject"
]
resources = [
"arn:aws:s3:::${local.config_s3_bucket_name}/*"
]
}
statement {
sid = "OrgAccountsAcl"
effect = "Allow"
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
}
actions = [
"s3:GetBucketAcl",
"s3:PutBucketAcl"
]
resources = [
"arn:aws:s3:::${local.config_s3_bucket_name}"
]
}
statement {
sid = "ConfigLogsAcl"
effect = "Allow"
principals {
type = "Service"
identifiers = ["config.amazonaws.com"]
}
actions = [
"s3:GetBucketAcl"
]
resources = [
"arn:aws:s3:::${local.config_s3_bucket_name}"
]
}
}
resource "aws_s3_bucket" "config" {
count = var.enable_config_baseline ? 1 : 0
bucket = local.config_s3_bucket_name
acl = "private"
policy = data.aws_iam_policy_document.s3_policy_config[0].json
lifecycle {
ignore_changes = [
versioning,
grant
]
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
lifecycle_rule {
id = "ARCHIVING"
enabled = true
transition {
days = 30
storage_class = "STANDARD_IA"
}
transition {
days = 90
storage_class = "GLACIER"
}
}
}