Skip to content

Commit 55fb61d

Browse files
authored
Merge pull request #1 from rhythmictech/demo
Demo
2 parents 57794af + 50b1c07 commit 55fb61d

File tree

7 files changed

+92
-101
lines changed

7 files changed

+92
-101
lines changed

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# terraform-anycloud-template [![](https://github.com/rhythmictech/terraform-anycloud-template/workflows/pre-commit-check/badge.svg)](https://github.com/rhythmictech/terraform-anycloud-template/actions) <a href="https://twitter.com/intent/follow?screen_name=RhythmicTech"><img src="https://img.shields.io/twitter/follow/RhythmicTech?style=social&logo=RhythmicTech" alt="follow on Twitter"></a>
1+
# terraform-aws-securityhub-to-sns [![](https://github.com/rhythmictech/terraform-aws-securityhub-to-sns/workflows/pre-commit-check/badge.svg)](https://github.com/rhythmictech/terraform-aws-securityhub-to-sns/actions) <a href="https://twitter.com/intent/follow?screen_name=RhythmicTech"><img src="https://img.shields.io/twitter/follow/RhythmicTech?style=social&logo=RhythmicTech" alt="follow on Twitter"></a>
22
Template repository for terraform modules. Good for any cloud and any provider.
33

44
## Example
55
Here's what using the module will look like
66
```
77
module "example" {
8-
source = "rhythmictech/terraform-mycloud-mymodule
8+
source = "rhythmictech/terraform-aws-securityhub-to-sns
9+
custom_action_notification_arn = "arn:aws:sns:us-east-1:012345678912:CreateTicket"
10+
imported_finding_notification_arn = "arn:aws:sns:us-east-1:012345678912:NotifySlack"
911
}
1012
```
1113

12-
## About
13-
A bit about this module
1414

1515
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1616
## Requirements
@@ -19,25 +19,21 @@ No requirements.
1919

2020
## Providers
2121

22-
No provider.
22+
| Name | Version |
23+
|------|---------|
24+
| aws | n/a |
2325

2426
## Inputs
2527

2628
| Name | Description | Type | Default | Required |
2729
|------|-------------|------|---------|:--------:|
28-
| name | Moniker to apply to all resources in the module | `string` | n/a | yes |
30+
| custom\_action\_notification\_arn | Notification ARN to send custom actions to (leave blank if not using custom actions) | `string` | `null` | no |
31+
| imported\_finding\_notification\_arn | Notification ARN to send imported findings to (leave blank if not using custom actions) | `string` | `null` | no |
32+
| name | Moniker to apply to or prefix all resources in the module | `string` | `"securityhub"` | no |
2933
| tags | User-Defined tags | `map(string)` | `{}` | no |
3034

3135
## Outputs
3236

33-
| Name | Description |
34-
|------|-------------|
35-
| tags\_module | Tags Module in it's entirety |
37+
No output.
3638

3739
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
38-
39-
## The Giants underneath this module
40-
- pre-commit.com/
41-
- terraform.io/
42-
- github.com/tfutils/tfenv
43-
- github.com/segmentio/terraform-docs

examples/basic/README.md

Lines changed: 0 additions & 59 deletions
This file was deleted.

examples/basic/main.tf

Lines changed: 0 additions & 10 deletions
This file was deleted.

locals.tf

Lines changed: 0 additions & 5 deletions
This file was deleted.

main.tf

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,63 @@
11

2-
module "tags" {
3-
source = "rhythmictech/tags/terraform"
4-
version = "1.0.0"
2+
resource "aws_securityhub_account" "this" {}
53

6-
enforce_case = "UPPER"
7-
names = [var.name]
8-
tags = var.tags
4+
# NOTE: Security Hub now enables these by default
5+
# resource "aws_securityhub_product_subscription" "guardduty" {
6+
# depends_on = [aws_securityhub_account.account]
7+
# product_arn = "arn:aws:securityhub:${var.region}::product/aws/guardduty"
8+
# }
9+
10+
# resource "aws_securityhub_standards_subscription" "cis" {
11+
# depends_on = [aws_securityhub_account.account]
12+
# standards_arn = "arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/1.2.0"
13+
# }
14+
15+
resource "aws_cloudwatch_event_rule" "imported" {
16+
count = var.imported_finding_notification_arn == null ? 0 : 1
17+
name = "${var.name}-imported-findings"
18+
description = "SecurityHubEvent - Imported Findings"
19+
tags = var.tags
20+
21+
event_pattern = <<PATTERN
22+
{
23+
"source": [
24+
"aws.securityhub"
25+
],
26+
"detail-type": [
27+
"Security Hub Findings - Imported"
28+
]
29+
}
30+
PATTERN
31+
}
32+
33+
resource "aws_cloudwatch_event_target" "imported" {
34+
count = var.imported_finding_notification_arn == null ? 0 : 1
35+
rule = aws_cloudwatch_event_rule.imported[0].name
36+
target_id = "SendToSNS"
37+
arn = var.imported_finding_notification_arn
38+
}
39+
40+
resource "aws_cloudwatch_event_rule" "custom_action" {
41+
count = var.custom_action_notification_arn == null ? 0 : 1
42+
name = "${var.name}-custom-action"
43+
description = "SecurityHubEvent - Custom Action"
44+
tags = var.tags
45+
46+
event_pattern = <<PATTERN
47+
{
48+
"source": [
49+
"aws.securityhub"
50+
],
51+
"detail-type": [
52+
"Security Hub Findings - Custom Action"
53+
]
54+
}
55+
PATTERN
56+
}
57+
58+
resource "aws_cloudwatch_event_target" "custom_action" {
59+
count = var.custom_action_notification_arn == null ? 0 : 1
60+
rule = aws_cloudwatch_event_rule.custom_action[0].name
61+
target_id = "SendToSNS"
62+
arn = var.custom_action_notification_arn
963
}

outputs.tf

Lines changed: 0 additions & 5 deletions
This file was deleted.

variables.tf

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
########################################
2+
# General Vars
3+
########################################
14

25
variable "name" {
3-
description = "Moniker to apply to all resources in the module"
6+
default = "securityhub"
7+
description = "Moniker to apply to or prefix all resources in the module"
48
type = string
59
}
610

@@ -9,3 +13,19 @@ variable "tags" {
913
description = "User-Defined tags"
1014
type = map(string)
1115
}
16+
17+
########################################
18+
# Notification ARNs
19+
########################################
20+
21+
variable "custom_action_notification_arn" {
22+
default = null
23+
description = "Notification ARN to send custom actions to (leave blank if not using custom actions)"
24+
type = string
25+
}
26+
27+
variable "imported_finding_notification_arn" {
28+
default = null
29+
description = "Notification ARN to send imported findings to (leave blank if not using custom actions)"
30+
type = string
31+
}

0 commit comments

Comments
 (0)