-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathkms.tf
36 lines (29 loc) · 787 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
# This data source is necessary to get the current aws account id to set in
# the key policy
data "aws_caller_identity" "current" {}
data "aws_iam_policy_document" "key_policy" {
statement {
sid = "Allow IAM permissions"
effect = "Allow"
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:root",
]
}
actions = [
"kms:*",
]
resources = [
"*",
]
}
}
resource "aws_kms_key" "credstash_cmk" {
description = "KMS key used by credstash for encrypt/decrypt"
policy = "${data.aws_iam_policy_document.key_policy.json}"
}
resource "aws_kms_alias" "alias" {
name = "${var.key_alias}"
target_key_id = "${aws_kms_key.credstash_cmk.key_id}"
}