-
Notifications
You must be signed in to change notification settings - Fork 2
/
aws_kms_key.alarms.tf
46 lines (42 loc) · 1.1 KB
/
aws_kms_key.alarms.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
# you can't use a managed key to write to an encrypted SNS from a cloudwatch alarm
resource "aws_kms_key" "alarm" {
policy = <<POLICY
{
"Version": "2012-10-17",
"Id": "key-consolepolicy-3",
"Statement": [
{
"Sid": "Allow_CloudWatch_for_CMK",
"Effect": "Allow",
"Principal": {
"Service": "cloudwatch.amazonaws.com"
},
"Action": [
"kms:Decrypt",
"kms:GenerateDataKey*"
],
"Resource": "*"
},
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"
},
"Action": "kms:*",
"Resource": "*"
}
]
}
POLICY
enable_key_rotation = true
}
resource "aws_kms_alias" "alarm" {
target_key_id = aws_kms_key.alarm.id
name = var.kms-alias
}
data "aws_caller_identity" "current" {}
variable "kms-alias" {
type = string
default = "alias/alarms"
}