forked from GSA/grace-inventory
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kms.tf
47 lines (43 loc) · 1008 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
45
46
resource "aws_kms_key" "kms_key" {
description = "Key for GRACE service inventory reporting S3 bucket"
deletion_window_in_days = 7
enable_key_rotation = "true"
depends_on = [aws_iam_role.iam_role]
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${local.account_id}:root"
},
"Action": "kms:*",
"Resource": "*"
},
{
"Sid": "Allow use of the key",
"Effect": "Allow",
"Principal": {
"AWS": [
"${aws_iam_role.iam_role.arn}"
]
},
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "*"
}
]
}
EOF
}
resource "aws_kms_alias" "kms_alias" {
name = "alias/${local.app_name}"
target_key_id = aws_kms_key.kms_key.key_id
}