-
Notifications
You must be signed in to change notification settings - Fork 0
/
kms.tf
42 lines (36 loc) · 924 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
data "aws_caller_identity" "current" {}
locals {
account_id = data.aws_caller_identity.current.account_id
}
data "aws_iam_policy_document" "kms_key" {
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 = ["*"]
principals {
type = "AWS"
identifiers = [aws_iam_role.aws_backup_service_role.arn]
}
}
}
resource "aws_kms_key" "vault_kms_key" {
description = "This key is used to encrypt backups in vault"
policy = data.aws_iam_policy_document.kms_key.json
}