-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkms.tf
More file actions
39 lines (30 loc) · 937 Bytes
/
kms.tf
File metadata and controls
39 lines (30 loc) · 937 Bytes
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
locals {
key_purposes = toset(["root", "worker-auth", "recovery"])
}
resource "aws_kms_key" "key" {
for_each = local.key_purposes
description = "resinstack:boundary:${each.value}:${var.cluster_tag}"
enable_key_rotation = var.enable_key_rotation
tags = {
"resinstack:cluster" = var.cluster_tag
}
}
data "aws_iam_policy_document" "kms_policy" {
for_each = local.key_purposes
statement {
sid = "BoundaryKMS${replace(each.value, "-", "")}"
effect = "Allow"
resources = [aws_kms_key.key[each.value].arn]
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:DescribeKey",
]
}
}
resource "aws_iam_policy" "kms_policy" {
for_each = local.key_purposes
name = "ResinStackBoundaryKMS-${each.value}-${var.cluster_tag}"
description = "Allow access to boundary KMS purpose=${each.value}"
policy = data.aws_iam_policy_document.kms_policy[each.value].json
}