-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkms_default.tf
59 lines (57 loc) · 1.53 KB
/
kms_default.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
resource "aws_kms_key" "default" {
count = var.encrypt_at_rest ? 1 : 0
description = "KMS key for at rest encryption"
deletion_window_in_days = 10
policy = data.aws_iam_policy_document.kms_default[0].json
}
data "aws_iam_policy_document" "kms_default" {
count = var.encrypt_at_rest ? 1 : 0
statement {
sid = "Enable IAM User Permissions"
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${local.account_id}:root"]
}
actions = ["kms:*"]
resources = ["*"]
}
statement {
sid = "Allow use of the key"
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${local.account_id}:role/aws-elasticbeanstalk-ec2-role",
"arn:aws:iam::${local.account_id}:role/aws-elasticbeanstalk-service-role"
]
}
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey",
]
resources = ["*"]
}
statement {
sid = "Allow attachment of persistent resources"
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${local.account_id}:role/aws-elasticbeanstalk-ec2-role",
"arn:aws:iam::${local.account_id}:role/aws-elasticbeanstalk-service-role"
]
}
actions = [
"kms:CreateGrant",
"kms:ListGrants",
"kms:RevokeGrant",
]
resources = ["*"]
condition {
test = "Bool"
variable = "kms:GrantIsForAWSResource"
values = ["true"]
}
}
}