-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkms.tf
44 lines (38 loc) · 994 Bytes
/
kms.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
resource "aws_kms_alias" "securityhub_alias" {
name = "alias/securityhub-key"
target_key_id = aws_kms_key.securityhub_key.key_id
}
resource "aws_kms_key" "securityhub_key" {
description = "KMS KEY for securityhub exporter lambda"
policy = data.aws_iam_policy_document.kms_key_policy.json
}
data "aws_iam_policy_document" "kms_key_policy" {
statement {
sid = "Enable IAM User Permissions"
effect = "Allow"
actions = ["kms:*"]
resources = ["*"]
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${local.account_id}:root"]
}
}
statement {
sid = "Allow use of the key"
effect = "Allow"
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey",
]
resources = [aws_s3_bucket.securityhub_bucket.arn]
principals {
type = "AWS"
identifiers = [
aws_iam_role.lambda.arn,
]
}
}
}