forked from trussworks/terraform-aws-guardduty-notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
48 lines (38 loc) · 1.25 KB
/
main.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
#
# GuardDuty
#
resource "aws_guardduty_detector" "main" {
count = var.create_detector ? 1 : 0
enable = true
}
#
# CloudWatch Event
#
resource "aws_cloudwatch_event_rule" "main" {
name = "guardduty-finding-events"
description = "AWS GuardDuty event findings"
event_pattern = file("${path.module}/event-pattern.json")
}
# More details about the response syntax can be found here:
# https://docs.aws.amazon.com/guardduty/latest/ug/get-findings.html#get-findings-response-syntax
resource "aws_cloudwatch_event_target" "slack" {
count = var.slack_notifications ? 1 : 0
rule = aws_cloudwatch_event_rule.main.name
target_id = "send-to-sns-slack"
arn = var.sns_topic_slack_arn
input_transformer {
input_paths = {
title = "$.detail.title"
description = "$.detail.description"
eventTime = "$.detail.service.eventFirstSeen"
region = "$.detail.region"
}
input_template = "\"GuardDuty finding in <region> first seen at <eventTime>: <title> <description>\""
}
}
resource "aws_cloudwatch_event_target" "pagerduty" {
count = var.pagerduty_notifications ? 1 : 0
rule = aws_cloudwatch_event_rule.main.name
target_id = "send-to-sns-pagerduty"
arn = var.sns_topic_pagerduty_arn
}