Skip to content

Commit c5d97b4

Browse files
authored
Merge pull request #23 from rhythmictech/securityhub
add configurable support for securityhub integration
2 parents 260451b + 2579c66 commit c5d97b4

12 files changed

Lines changed: 293 additions & 2 deletions

File tree

.terraform.lock.hcl

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module "datadog" {
9999
| <a name="requirement_datadog"></a> [datadog](#requirement\_datadog) | >= 3.37 |
100100
| <a name="requirement_http"></a> [http](#requirement\_http) | >= 3.4 |
101101
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.1.0 |
102+
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.12 |
102103

103104
## Providers
104105

@@ -109,6 +110,7 @@ module "datadog" {
109110
| <a name="provider_datadog"></a> [datadog](#provider\_datadog) | 3.37.0 |
110111
| <a name="provider_http"></a> [http](#provider\_http) | 3.4.2 |
111112
| <a name="provider_null"></a> [null](#provider\_null) | 3.2.2 |
113+
| <a name="provider_time"></a> [time](#provider\_time) | 0.12.1 |
112114

113115
## Modules
114116

@@ -123,8 +125,10 @@ module "datadog" {
123125
| [aws_cloudformation_stack.datadog_forwarder](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack) | resource |
124126
| [aws_cloudwatch_event_rule.awshealth](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource |
125127
| [aws_cloudwatch_event_rule.guardduty](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource |
128+
| [aws_cloudwatch_event_rule.securityhub_to_datadog](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource |
126129
| [aws_cloudwatch_event_target.awshealth](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource |
127130
| [aws_cloudwatch_event_target.guardduty](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource |
131+
| [aws_cloudwatch_event_target.securityhub_to_datadog](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource |
128132
| [aws_cloudwatch_log_subscription_filter.cloudwatch_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_subscription_filter) | resource |
129133
| [aws_cloudwatch_log_subscription_filter.rds_enhanced_monitoring](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_subscription_filter) | resource |
130134
| [aws_cur_report_definition.cur](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cur_report_definition) | resource |
@@ -146,6 +150,7 @@ module "datadog" {
146150
| [aws_lambda_permission.bucket_trigger](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
147151
| [aws_lambda_permission.cloudwatch_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
148152
| [aws_lambda_permission.guardduty_trigger](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
153+
| [aws_lambda_permission.securityhub_trigger](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
149154
| [aws_s3_bucket.local_cur](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
150155
| [aws_s3_bucket_lifecycle_configuration.local_cur](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
151156
| [aws_s3_bucket_notification.bucket_notification](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_notification) | resource |
@@ -164,6 +169,7 @@ module "datadog" {
164169
| [datadog_monitor.anomaly_usage](https://registry.terraform.io/providers/datadog/datadog/latest/docs/resources/monitor) | resource |
165170
| [datadog_monitor.forecast_usage](https://registry.terraform.io/providers/datadog/datadog/latest/docs/resources/monitor) | resource |
166171
| [null_resource.rds_enhanced_monitoring](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
172+
| [time_sleep.wait_datadog_forwarder](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
167173
| [archive_file.rds_enhanced_monitoring](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
168174
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
169175
| [aws_iam_policy_document.assume](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
@@ -190,6 +196,7 @@ module "datadog" {
190196
| <a name="input_enable_health_notifications"></a> [enable\_health\_notifications](#input\_enable\_health\_notifications) | Send AWS health notifications to Datadog (`install_log_forwarder` must be true). This routes AWS Health events to the log forwarder. Health events can also be received as a Datadog Event through the AWS Health integration. | `bool` | `true` | no |
191197
| <a name="input_enable_rds_enhanced_monitoring_lambda"></a> [enable\_rds\_enhanced\_monitoring\_lambda](#input\_enable\_rds\_enhanced\_monitoring\_lambda) | Install the RDS Enhanced Monitoring Lambda | `bool` | `false` | no |
192198
| <a name="input_enable_resource_collection"></a> [enable\_resource\_collection](#input\_enable\_resource\_collection) | Enable or disable resource collection | `bool` | `true` | no |
199+
| <a name="input_enable_securityhub_notifications"></a> [enable\_securityhub\_notifications](#input\_enable\_securityhub\_notifications) | Send Security Hub notifications to Datadog (`install_log_forwarder` must be true). This routes Security Hub events to the log forwarder. | `bool` | `false` | no |
193200
| <a name="input_estimated_usage_anomaly_message"></a> [estimated\_usage\_anomaly\_message](#input\_estimated\_usage\_anomaly\_message) | Message for usage anomaly alerts | `string` | `"Datadog usage anomaly detected"` | no |
194201
| <a name="input_estimated_usage_detection_config"></a> [estimated\_usage\_detection\_config](#input\_estimated\_usage\_detection\_config) | Map of usage types to monitor. | `map(any)` | `{}` | no |
195202
| <a name="input_estimated_usage_detection_default_config"></a> [estimated\_usage\_detection\_default\_config](#input\_estimated\_usage\_detection\_default\_config) | Map of default usage monitoring settings for each metric type. All are disabled by default. Use `usage_anomaly_services` to enable services and alternately override default settings | <pre>map(object({<br> anomaly_enabled = bool<br> anomaly_span = string<br> anomaly_threshold = number<br> anomaly_window = string<br> anomaly_deviations = number<br> anomaly_seasonality = string<br> anomaly_rollup = number<br> forecast_enabled = bool<br> forecast_deviations = number<br> forecast_rollup_type = string<br> forecast_rollup_value = number<br> forecast_threshold = number<br> }))</pre> | <pre>{<br> "hosts": {<br> "anomaly_deviations": 1,<br> "anomaly_enabled": false,<br> "anomaly_rollup": 600,<br> "anomaly_seasonality": "daily",<br> "anomaly_span": "last_1d",<br> "anomaly_threshold": 0.15,<br> "anomaly_window": "last_1h",<br> "forecast_deviations": 1,<br> "forecast_enabled": false,<br> "forecast_rollup_type": "avg",<br> "forecast_rollup_value": 300,<br> "forecast_threshold": 1000<br> },<br> "logs_indexed": {<br> "anomaly_deviations": 2,<br> "anomaly_enabled": false,<br> "anomaly_rollup": 60,<br> "anomaly_seasonality": "hourly",<br> "anomaly_span": "last_1d",<br> "anomaly_threshold": 0.15,<br> "anomaly_window": "last_1h",<br> "forecast_deviations": 1,<br> "forecast_enabled": false,<br> "forecast_rollup_type": "sum",<br> "forecast_rollup_value": 86400,<br> "forecast_threshold": 1000<br> },<br> "logs_ingested": {<br> "anomaly_deviations": 2,<br> "anomaly_enabled": false,<br> "anomaly_rollup": 60,<br> "anomaly_seasonality": "hourly",<br> "anomaly_span": "last_1d",<br> "anomaly_threshold": 0.15,<br> "anomaly_window": "last_1h",<br> "forecast_deviations": 1,<br> "forecast_enabled": false,<br> "forecast_rollup_type": "sum",<br> "forecast_rollup_value": 86400,<br> "forecast_threshold": 1000<br> }<br>}</pre> | no |

examples/basic/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ terraform {
1919
source = "hashicorp/null"
2020
version = ">= 3.1.0"
2121
}
22+
23+
time = {
24+
source = "hashicorp/time"
25+
version = ">= 0.12"
26+
}
2227
}
2328
}
2429

examples/log_exclusions/.terraform.lock.hcl

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/log_exclusions/main.tf

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
terraform {
2+
required_providers {
3+
archive = {
4+
source = "hashicorp/archive"
5+
version = ">= 2.2.0"
6+
}
7+
8+
aws = {
9+
source = "hashicorp/aws"
10+
version = ">= 4.62"
11+
}
12+
13+
datadog = {
14+
source = "datadog/datadog"
15+
version = ">= 3.37"
16+
}
17+
18+
null = {
19+
source = "hashicorp/null"
20+
version = ">= 3.1.0"
21+
}
22+
23+
time = {
24+
source = "hashicorp/time"
25+
version = ">= 0.12"
26+
}
27+
}
28+
}
29+
30+
provider "aws" {
31+
}
32+
33+
provider "datadog" {
34+
api_key = var.datadog_api_key
35+
app_key = var.datadog_app_key
36+
}
37+
38+
module "datadog" {
39+
source = "../.."
40+
41+
name = "datadog-integration"
42+
install_log_forwarder = true
43+
integration_filter_tags = ["datadog_managed:true"]
44+
45+
# logs
46+
logs_manage_main_index = true
47+
logs_main_index_exclusion_filters = [
48+
{
49+
name = "Exclude Datadog agent logs"
50+
is_enabled = true
51+
filter = {
52+
query = "source:runtime-security-agent"
53+
sample_rate = 0
54+
}
55+
},
56+
{
57+
name = "Exclude Datadog CloudTrail logs"
58+
is_enabled = true
59+
filter = {
60+
query = "service:cloudtrail @userIdentity.assumed_role:DatadogIntegrationRole status:info"
61+
sample_rate = 0
62+
}
63+
}
64+
]
65+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "datadog_api_key" {
2+
description = "Datadog API key"
3+
type = string
4+
}
5+
6+
variable "datadog_app_key" {
7+
description = "Datadog APP key"
8+
type = string
9+
}

examples/with_style/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ terraform {
1919
source = "hashicorp/null"
2020
version = ">= 3.1.0"
2121
}
22+
23+
time = {
24+
source = "hashicorp/time"
25+
version = ">= 0.12"
26+
}
2227
}
2328
}
2429

iam-fullperms.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"bcm-data-exports:GetExport",
99
"bcm-data-exports:ListExports",
1010
"budgets:ViewBudget",
11+
"cassandra:Select",
1112
"cloudfront:GetDistributionConfig",
1213
"cloudfront:ListDistributions",
1314
"cloudtrail:DescribeTrails",
@@ -23,6 +24,7 @@
2324
"dynamodb:Describe*",
2425
"dynamodb:List*",
2526
"ec2:Describe*",
27+
"ec2:GetSnapshotBlockPublicAccessState",
2628
"ec2:GetTransitGatewayPrefixListReferences",
2729
"ec2:SearchTransitGatewayRoutes",
2830
"ecs:Describe*",
@@ -41,13 +43,16 @@
4143
"events:CreateEventBus",
4244
"fsx:DescribeFileSystems",
4345
"fsx:ListTagsForResource",
46+
"glacier:GetVaultNotifications",
47+
"glue:ListRegistries",
4448
"health:DescribeAffectedEntities",
4549
"health:DescribeEventDetails",
4650
"health:DescribeEvents",
4751
"kinesis:Describe*",
4852
"kinesis:List*",
4953
"lambda:GetPolicy",
5054
"lambda:List*",
55+
"lightsail:GetInstancePortStates",
5156
"logs:DeleteSubscriptionFilter",
5257
"logs:DescribeLogGroups",
5358
"logs:DescribeLogStreams",
@@ -70,6 +75,8 @@
7075
"s3:GetBucketTagging",
7176
"s3:ListAllMyBuckets",
7277
"s3:PutBucketNotification",
78+
"savingsplans:DescribeSavingsPlanRates",
79+
"savingsplans:DescribeSavingsPlans",
7380
"ses:Get*",
7481
"sns:GetSubscriptionAttributes",
7582
"sns:List*",
@@ -82,7 +89,15 @@
8289
"tag:GetResources",
8390
"tag:GetTagKeys",
8491
"tag:GetTagValues",
92+
"timestream:DescribeEndpoints",
93+
"waf-regional:ListRuleGroups",
94+
"waf-regional:ListRules",
95+
"waf:ListRuleGroups",
96+
"waf:ListRules",
97+
"wafv2:GetIPSet",
8598
"wafv2:GetLoggingConfiguration",
99+
"wafv2:GetRegexPatternSet",
100+
"wafv2:GetRuleGroup",
86101
"wafv2:ListLoggingConfigurations",
87102
"xray:BatchGetTraces",
88103
"xray:GetTraceSummaries"

logforward.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ resource "datadog_integration_aws_lambda_arn" "datadog_forwarder" {
2222
depends_on = [aws_cloudformation_stack.datadog_forwarder]
2323
}
2424

25+
resource "time_sleep" "wait_datadog_forwarder" {
26+
create_duration = "30s"
27+
28+
depends_on = [datadog_integration_aws_lambda_arn.datadog_forwarder]
29+
}
30+
2531
resource "datadog_integration_aws_log_collection" "datadog_forwarder" {
2632
count = var.install_log_forwarder ? 1 : 0
2733
account_id = local.account_id
2834
services = var.log_forwarder_sources
2935

30-
depends_on = [aws_cloudformation_stack.datadog_forwarder]
36+
depends_on = [time_sleep.wait_datadog_forwarder]
3137
}
3238

3339
resource "aws_lambda_permission" "bucket_trigger" {

0 commit comments

Comments
 (0)