forked from DNXLabs/terraform-aws-guardduty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudwatch-event.tf
35 lines (30 loc) · 1.17 KB
/
cloudwatch-event.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
resource "aws_cloudwatch_event_rule" "guardduty" {
count = var.sns_topic_name != "" ? 1 : 0
name = "guardduty-events"
description = "GuardDutyEvent"
# is_enabled = var.guardduty_enabled
# tags = var.tags
event_pattern = var.event_pattern
}
resource "aws_cloudwatch_event_target" "guardduty" {
count = var.sns_topic_name != "" ? 1 : 0
rule = aws_cloudwatch_event_rule.guardduty[0].name
target_id = "SendToSNS"
arn = aws_sns_topic.default[0].arn
input_transformer {
input_paths = {
"Account_ID" : "$.detail.accountId",
"Finding_ID" : "$.detail.id",
"Finding_Type" : "$.detail.type",
"Finding_description" : "$.detail.description",
"region" : "$.region",
"severity" : "$.detail.severity"
}
input_template = <<INPUT_TEMPLATE_EOF
"AWS <Account_ID> has a severity <severity> GuardDuty finding type <Finding_Type> in the <region> region."
"Finding Description:"
"<Finding_description>. "
"For more details open the GuardDuty console at https://console.aws.amazon.com/guardduty/home?region=<region>#/findings?search=id=<Finding_ID>"
INPUT_TEMPLATE_EOF
}
}