-
Notifications
You must be signed in to change notification settings - Fork 1
/
kms.tf
64 lines (57 loc) · 1.27 KB
/
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
60
61
62
63
64
data "aws_iam_policy_document" "key" {
statement {
effect = "Allow"
actions = ["kms:*"]
resources = ["*"]
principals {
type = "AWS"
identifiers = ["arn:${local.partition}:iam::${local.account_id}:root"]
}
}
statement {
effect = "Allow"
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey",
]
resources = ["*"]
principals {
type = "Service"
identifiers = ["delivery.logs.amazonaws.com"]
}
}
statement {
effect = "Allow"
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey",
]
resources = ["*"]
principals {
type = "Service"
identifiers = ["logs.${var.region}.amazonaws.com"]
}
}
}
resource "aws_kms_key" "this" {
deletion_window_in_days = 7
description = "VPC Flow Log Encryption Key"
enable_key_rotation = true
policy = data.aws_iam_policy_document.key.json
tags = merge(
{
"Name" = "vpcflowlog-key"
},
var.tags
)
}
resource "aws_kms_alias" "this" {
name = "alias/vpcflowlog_key"
target_key_id = aws_kms_key.this.id
}