-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.tf
More file actions
63 lines (54 loc) · 1.77 KB
/
main.tf
File metadata and controls
63 lines (54 loc) · 1.77 KB
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
resource "aws_securityhub_account" "this" {}
# NOTE: Security Hub now enables these by default
# resource "aws_securityhub_product_subscription" "guardduty" {
# depends_on = [aws_securityhub_account.account]
# product_arn = "arn:aws:securityhub:${var.region}::product/aws/guardduty"
# }
# resource "aws_securityhub_standards_subscription" "cis" {
# depends_on = [aws_securityhub_account.account]
# standards_arn = "arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/1.2.0"
# }
resource "aws_cloudwatch_event_rule" "imported" {
count = var.imported_finding_notification_arn == null ? 0 : 1
name = "${var.name}-imported-findings"
description = "SecurityHubEvent - Imported Findings"
tags = var.tags
event_pattern = <<PATTERN
{
"source": [
"aws.securityhub"
],
"detail-type": [
"Security Hub Findings - Imported"
]
}
PATTERN
}
resource "aws_cloudwatch_event_target" "imported" {
count = var.imported_finding_notification_arn == null ? 0 : 1
rule = aws_cloudwatch_event_rule.imported[0].name
target_id = "SendToSNS"
arn = var.imported_finding_notification_arn
}
resource "aws_cloudwatch_event_rule" "custom_action" {
count = var.custom_action_notification_arn == null ? 0 : 1
name = "${var.name}-custom-action"
description = "SecurityHubEvent - Custom Action"
tags = var.tags
event_pattern = <<PATTERN
{
"source": [
"aws.securityhub"
],
"detail-type": [
"Security Hub Findings - Custom Action"
]
}
PATTERN
}
resource "aws_cloudwatch_event_target" "custom_action" {
count = var.custom_action_notification_arn == null ? 0 : 1
rule = aws_cloudwatch_event_rule.custom_action[0].name
target_id = "SendToSNS"
arn = var.custom_action_notification_arn
}