generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_kms.tf
59 lines (49 loc) · 1.43 KB
/
module_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module "kms" {
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/kms?ref=v1.0.8"
providers = {
aws = aws.us-east-1
}
aws_account_id = var.aws_account_id
component = var.component
environment = var.environment
project = var.project
region = "us-east-1"
name = "main"
deletion_window = var.kms_deletion_window
alias = "alias/${local.csi}"
key_policy_documents = [data.aws_iam_policy_document.kms.json]
iam_delegation = true
}
data "aws_iam_policy_document" "kms" {
# '*' resource scope is permitted in access policies as as the resource is itself
# https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-services.html
statement {
sid = "AllowCloudWatchEncrypt"
effect = "Allow"
principals {
type = "Service"
identifiers = [
"logs.${var.region}.amazonaws.com",
"logs.us-east-1.amazonaws.com",
]
}
actions = [
"kms:Encrypt*",
"kms:Decrypt*",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:Describe*"
]
resources = [
"*",
]
condition {
test = "ArnLike"
variable = "kms:EncryptionContext:aws:logs:arn"
values = [
"arn:aws:logs:${var.region}:${var.aws_account_id}:log-group:*",
"arn:aws:logs:us-east-1:${var.aws_account_id}:log-group:*",
]
}
}
}