-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkms.tf
More file actions
198 lines (179 loc) · 6.82 KB
/
kms.tf
File metadata and controls
198 lines (179 loc) · 6.82 KB
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
module "cloudtrail_kms" {
source = "terraform-aws-modules/kms/aws"
version = "3.0.0"
aliases = ["${local.cluster_name}-cloudtrail"]
bypass_policy_lockout_safety_check = false
create = true
deletion_window_in_days = 30
description = "Encrypt and decrypt data for cloudtrail"
enable_default_policy = true
enable_key_rotation = true
is_enabled = true
key_administrators = [data.aws_caller_identity.current.arn] # Needs to change to the specific need-to-know roles
key_owners = [data.aws_caller_identity.current.arn]
rotation_period_in_days = 90
key_statements = [
{
sid = "Enable CloudTrail Permissions"
actions = ["kms:GenerateDataKey*", "kms:DescribeKey"]
principals = [
{
type = "Service"
identifiers = ["cloudtrail.amazonaws.com"]
}
]
resources = ["*"]
condition = [
{
test = "StringLike"
variable = "kms:EncryptionContext:aws:cloudtrail:arn"
values = [
"arn:${data.aws_partition.current.partition}:cloudtrail:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:trail/*"
]
}
]
},
{
sid = "Enable users to decrypt"
actions = ["kms:Decrypt"]
principals = [
{
type = "AWS"
identifiers = ["*"]
}
]
resources = [data.aws_s3_bucket.logs.arn]
condition = [
{
test = "Null"
variable = "kms:EncryptionContext:aws:cloudtrail:arn"
values = ["false"]
}
]
}
]
tags = merge(local.tags_for_all_resources, {
Name = "CloudTrail"
})
}
module "cloudwatch_kms" {
source = "terraform-aws-modules/kms/aws"
version = "3.0.0"
aliases = ["${local.cluster_name}-cloudwatch"]
bypass_policy_lockout_safety_check = false
create = true
deletion_window_in_days = 7
description = "Encrypt and decrypt data for cloudwatch"
enable_default_policy = true
enable_key_rotation = true
is_enabled = true
key_administrators = [data.aws_caller_identity.current.arn] # Needs to change to the specific need-to-know roles
key_owners = [data.aws_caller_identity.current.arn]
key_usage = "ENCRYPT_DECRYPT"
rotation_period_in_days = 90
key_statements = [
{
sid = "AllowCloudwatchLogging",
effect = "Allow",
actions = [
"kms:Encrypt*",
"kms:Decrypt*",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:Describe*"
],
resources = ["*"],
principals = [
{
type = "Service",
identifiers = ["logs.${data.aws_region.current.name}.amazonaws.com"]
}
]
}
]
tags = merge(local.tags_for_all_resources, {
Name = "CloudWatch"
})
}
module "ebs_kms" {
source = "terraform-aws-modules/kms/aws"
version = "3.0.0"
aliases = ["${local.cluster_name}-ebs"]
bypass_policy_lockout_safety_check = false
create = true
deletion_window_in_days = 7
description = "Encrypt and decrypt data for EBS"
enable_default_policy = true
enable_key_rotation = true
is_enabled = true
key_administrators = [data.aws_caller_identity.current.arn] # Needs to change to the specific need-to-know roles
key_owners = [data.aws_caller_identity.current.arn]
key_usage = "ENCRYPT_DECRYPT"
key_users = ["*"]
rotation_period_in_days = 90
tags = merge(local.tags_for_all_resources, {
Name = "EBS"
})
}
module "efs_kms" {
source = "terraform-aws-modules/kms/aws"
version = "3.0.0"
aliases = ["${local.cluster_name}-efs"]
bypass_policy_lockout_safety_check = false
create = true
deletion_window_in_days = 7
description = "Encrypt and decrypt data for EFS"
enable_default_policy = true
enable_key_rotation = true
is_enabled = true
key_administrators = [data.aws_caller_identity.current.arn] # Needs to change to the specific need-to-know roles
key_owners = [data.aws_caller_identity.current.arn]
key_usage = "ENCRYPT_DECRYPT"
key_users = ["*"]
rotation_period_in_days = 90
tags = merge(local.tags_for_all_resources, {
Name = "EFS"
})
}
module "s3_kms" {
source = "terraform-aws-modules/kms/aws"
version = "3.0.0"
aliases = ["${local.cluster_name}-s3"]
bypass_policy_lockout_safety_check = false
create = true
deletion_window_in_days = 7
description = "Encrypt and decrypt data for S3"
enable_default_policy = true
enable_key_rotation = true
is_enabled = true
key_administrators = [data.aws_caller_identity.current.arn] # Needs to change to the specific need-to-know roles
key_owners = [data.aws_caller_identity.current.arn]
key_service_users = ["*"]
key_usage = "ENCRYPT_DECRYPT"
key_users = ["*"]
rotation_period_in_days = 90
tags = merge(local.tags_for_all_resources, {
Name = "S3"
})
}
module "ssm_kms" {
source = "terraform-aws-modules/kms/aws"
version = "3.0.0"
aliases = ["${local.cluster_name}-ssm"]
bypass_policy_lockout_safety_check = false
create = true
deletion_window_in_days = 7
description = "Encrypt and decrypt data for SSM"
enable_default_policy = true
enable_key_rotation = true
is_enabled = true
key_administrators = [data.aws_caller_identity.current.arn] # Needs to change to the specific need-to-know roles
key_owners = [data.aws_caller_identity.current.arn]
key_service_users = ["*"]
key_usage = "ENCRYPT_DECRYPT"
key_users = ["*"]
rotation_period_in_days = 90
tags = merge(local.tags_for_all_resources, {
Name = "SSM"
})
}