Skip to content

Commit 621840d

Browse files
committed
feat: adding organization configuration for inspector
1 parent 47dcd93 commit 621840d

File tree

6 files changed

+57
-2
lines changed

6 files changed

+57
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The `terraform-docs` utility is used to generate this README. Follow the below s
3838
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to the resources | `map(string)` | n/a | yes |
3939
| <a name="input_access_analyzer"></a> [access\_analyzer](#input\_access\_analyzer) | Configuration for the AWS Access Analyzer service | <pre>object({<br/> enable_unused_analyzer = optional(bool, true)<br/> # Indicates whether to enable the unused AWS Access Analyzer service<br/> unused_analyzer_name = optional(string, "lza-unused-access-analyzer")<br/> # The name of the unused AWS Access Analyzer service<br/> unused_access_age = optional(number, 90)<br/> })</pre> | `null` | no |
4040
| <a name="input_config"></a> [config](#input\_config) | Configuration for the securityhub organization managed rules | <pre>object({<br/> stackset_name_prefix = optional(string, "lza-config-")<br/> # The prefix added to the stacksets<br/> rule_groups = optional(map(object({<br/> associations = list(string)<br/> # List of organizational units to deploy the managed rules<br/> description = string<br/> # Description for the rule group<br/> enabled_regions = optional(list(string), null)<br/> # List of regions to enable these rules<br/> exclude_accounts = optional(list(string), null)<br/> # The list of accounts to exclude from the organization managed rule<br/> rules = map(object({<br/> description = string<br/> # The description of the organization managed rules<br/> identifier = string<br/> # The identifier of the organization managed rule<br/> inputs = optional(map(string), {})<br/> # The identifier of the organization managed rule scope<br/> resource_types = list(string)<br/> # The list of resource types to scope the organization managed rule<br/> max_execution_frequency = optional(string, null)<br/> # The max_execution_frequency of the rule<br/> }))<br/> })), {})<br/> # The configuration for the securityhub organization managed rules<br/> })</pre> | <pre>{<br/> "rule_groups": {}<br/>}</pre> | no |
41+
| <a name="input_inspector"></a> [inspector](#input\_inspector) | Organizational configuration for the AWS Inspector service | <pre>object({<br/> account_id = optional(string, null)<br/> # The delegated administrator account ID for the AWS Inspector service<br/> enable = optional(bool, false)<br/> # Indicates whether to enable the AWS Inspector service<br/> enable_ec2_scan = optional(bool, false)<br/> # Indicates whether to enable the AWS Inspector service for EC2 instances<br/> enable_ecr_scan = optional(bool, false)<br/> # Indicates whether to enable the AWS Inspector service for ECR repositories<br/> enable_lambda_scan = optional(bool, false)<br/> # Indicates whether to enable the AWS Inspector service for Lambda functions<br/> enable_lambda_code_scan = optional(bool, false)<br/> # Indicates whether to enable the AWS Inspector service for Lambda code<br/> })</pre> | <pre>{<br/> "enable": false<br/>}</pre> | no |
4142
| <a name="input_macie"></a> [macie](#input\_macie) | Configuration for the AWS Macie service | <pre>object({<br/> enable = optional(bool, false)<br/> # Indicates whether to enable the AWS Macie service should be enabled in all accounts<br/> excluded_accounts = optional(list(string), null)<br/> # The list of accounts to exclude from the AWS Macie service<br/> frequency = optional(string, "FIFTEEN_MINUTES")<br/> # The frequency at which the AWS Macie service should be enabled<br/> organizational_units = optional(list(string), null)<br/> # The list of member accounts to associate with the AWS Macie service<br/> stackset_name = optional(string, "lza-macie-configuration")<br/> })</pre> | `null` | no |
4243
| <a name="input_notifications"></a> [notifications](#input\_notifications) | Configuration for the notifications | <pre>object({<br/> email = optional(object({<br/> addresses = optional(list(string), [])<br/> }), null)<br/> slack = optional(object({<br/> lamdba_name = optional(string, "lz-securityhub-all-notifications-slack")<br/> webhook_url = string<br/> }), null)<br/> teams = optional(object({<br/> lamdba_name = optional(string, "lz-securityhub-all-notifications-teams")<br/> webhook_url = string<br/> }), null)<br/> })</pre> | <pre>{<br/> "email": {<br/> "addresses": []<br/> },<br/> "slack": null,<br/> "teams": null<br/>}</pre> | no |
4344
| <a name="input_securityhub"></a> [securityhub](#input\_securityhub) | Configuration for the securityhub | <pre>object({<br/> aggregator = optional(object({<br/> create = optional(bool, false)<br/> # Indicates whether to create the securityhub<br/> # Indicates whether to create the aggregator<br/> linking_mode = optional(string, "ALL_REGIONS")<br/> # Indicates whether to aggregate findings from all of the available regions<br/> specified_regions = optional(list(string), null)<br/> # A list of regions to aggregate findings from when using SPECIFIED_REGIONS linking mode<br/> }), {<br/> create = false<br/> linking_mode = "ALL_REGIONS"<br/> specified_regions = null<br/> }<br/> )<br/> # The configuration for the aggregator<br/> configuration = optional(object({<br/> auto_enable = optional(bool, true)<br/> # Indicates whether to automatically enable Security Hub<br/> auto_enable_standards = optional(string, "DEFAULT")<br/> # Indicates whether to automatically enable new controls and standards<br/> organization_configuration = object({<br/> configuration_type = optional(string, "CENTRAL")<br/> # Indicates whether to enable Security Hub as a standalone service or as an organization master<br/> })<br/> # The configuration for the organization<br/> }), {<br/> auto_enable = false<br/> auto_enable_standards = "DEFAULT"<br/> organization_configuration = {<br/> configuration_type = "CENTRAL"<br/> }<br/> })<br/> # The configuration for the securityhub<br/> notifications = optional(object({<br/> enable = optional(bool, false)<br/> # Indicates whether to enable the securityhub notifications<br/> eventbridge_rule_name = optional(string, "lza-securityhub-all-notifications")<br/> # The name of the event bridge rule<br/> severities = optional(list(string), ["CRITICAL", "HIGH"])<br/> # The list of severities to enable the notifications<br/> sns_topic_queue_name = optional(string, "lza-securityhub-all-notifications")<br/> # Name of the SNS topic to send the notifications<br/> }), {<br/> enable = false<br/> eventbridge_rule_name = "lza-securityhub-all-notifications"<br/> severities = []<br/> sns_topic_queue_name = "lza-securityhub-all-notifications"<br/> })<br/> # The configuration for the notifications<br/> policies = optional(map(object({<br/> enable = optional(bool, true)<br/> # Indicates whether the configuration policy is enabled<br/> description = string<br/> # The description of the configuration policy<br/> associations = optional(list(object({<br/> account_id = optional(string, null)<br/> # The account ID to associate with the policy<br/> organization_unit = optional(string, null)<br/> # The organization unit to associate with the policy<br/> })), [])<br/> # The list of associations for the configuration policy<br/> policy = object({<br/> enable = optional(bool, true)<br/> # Indicates whether the configuration policy is enabled<br/> standard_arns = list(string)<br/> # The ARNs of the standards to enable<br/> controls = object({<br/> disabled = optional(list(string), null)<br/> # The list of control identifiers to disable<br/> custom_parameter = optional(list(object({<br/> security_control_id = string<br/> # The ID of the security control<br/> parameter = object({<br/> name = string<br/> # The name of the parameter<br/> value_type = string<br/> # The type of the parameter<br/> enum = optional(object({<br/> value = string<br/> # The value of the parameter (if the type is ENUM)<br/> }), null)<br/> })<br/> # The parameter for the security control<br/> })), null)<br/> })<br/> # The parameter for the security control<br/> })<br/> # The configuration policy<br/> })), {})<br/> })</pre> | <pre>{<br/> "aggregator": {<br/> "create": false,<br/> "linking_mode": "ALL_REGIONS",<br/> "specified_regions": null<br/> },<br/> "configuration": {<br/> "auto_enable": false,<br/> "auto_enable_standards": "NONE",<br/> "organization_configuration": {<br/> "configuration_type": "CENTRAL"<br/> }<br/> },<br/> "policies": {}<br/>}</pre> | no |

locals.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ locals {
1919
pci_dss = "arn:aws:securityhub:${local.region}::standards/pci-dss/v/3.2.1"
2020
}
2121

22+
## A list of resources type to enable for inspector
23+
inspector_resources_types = [
24+
var.inspector.enable_ec2_scan ? "EC2" : null,
25+
var.inspector.enable_ecr_scan ? "ECR" : null,
26+
var.inspector.enable_lambda_code_scan ? "LAMBDA_CODE" : null,
27+
var.inspector.enable_lambda_scan ? "LAMBDA" : null,
28+
]
29+
2230
## A lost of policy associations
2331
policy_associations_all = flatten([
2432
for policy_name, policy in var.securityhub.policies : [

main.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ module "config_rule_groups" {
2222
})
2323
}
2424

25+
## AWS Inspector
26+
27+
28+
resource "aws_inspector2_enabler" "inspector" {
29+
count = var.inspector.enable ? 1 : 0
30+
31+
account_ids = [var.inspector.account_id]
32+
resource_types = local.inspector_resources_types
33+
}
34+
35+
## All new accounts will have inspector enabled for the following resource types, any
36+
## existing accounts will need to be enabled manually via the aws_inspector2_member_association
37+
resource "aws_inspector2_organization_configuration" "auto_enable_inspector_new_accounts" {
38+
auto_enable {
39+
ec2 = var.inspector.enable_ec2_scan
40+
ecr = var.inspector.enable_ecr_scan
41+
lambda = var.inspector.enable_lambda_scan
42+
lambda_code = var.inspector.enable_lambda_code_scan
43+
}
44+
}
45+
2546
## AWS Macie
2647

2748
## Provision the stackset to enable the macie service across all the accounts

modules/guardduty/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to the resources | `map(string)` | n/a | yes |
1313
| <a name="input_auto_enable_mode"></a> [auto\_enable\_mode](#input\_auto\_enable\_mode) | Indicates whether to auto-enable the AWS GuardDuty service in all accounts | `string` | `"ALL"` | no |
1414
| <a name="input_create"></a> [create](#input\_create) | Indicates we should create a detector within the region | `bool` | `false` | no |
15-
| <a name="input_detectors"></a> [detectors](#input\_detectors) | The configuration for the GuardDuty detectors | <pre>map(object({<br/> name = string<br/> # The name of the detector<br/> auto_enable = optional(string, "NONE")<br/> # The frequency of finding publishing<br/> additional_configuration = optional(map(object({<br/> auto_enable = optional(string, "NONE")<br/> # The status of the additional configuration<br/> })), {})<br/> }))</pre> | <pre>{<br/> "eks": {<br/> "auto_enable": "ALL",<br/> "name": "EKS_AUDIT_LOGS"<br/> },<br/> "eks_runtime_monitoring": {<br/> "additional_configuration": {<br/> "EKS_ADDON_MANAGEMENT": {<br/> "auto_enable": "NONE"<br/> }<br/> },<br/> "auto_enable": "NONE",<br/> "name": "EKS_RUNTIME_MONITORING"<br/> },<br/> "lambda": {<br/> "auto_enable": "NONE",<br/> "name": "LAMBDA_NETWORK_LOGS"<br/> },<br/> "malware": {<br/> "auto_enable": "NONE",<br/> "name": "EBS_MALWARE_PROTECTION"<br/> },<br/> "rds": {<br/> "auto_enable": "NONE",<br/> "name": "RDS_LOGIN_EVENTS"<br/> },<br/> "runtime_monitoring": {<br/> "additional_configuration": {<br/> "EC2_AGENT_MANAGEMENT": {<br/> "auto_enable": "NONE"<br/> },<br/> "ECS_FARGATE_AGENT_MANAGEMENT": {<br/> "auto_enable": "NONE"<br/> },<br/> "EKS_ADDON_MANAGEMENT": {<br/> "auto_enable": "NONE"<br/> }<br/> },<br/> "auto_enable": "NONE",<br/> "name": "RUNTIME_MONITORING"<br/> },<br/> "s3": {<br/> "auto_enable": "NONE",<br/> "name": "S3_DATA_EVENTS"<br/> }<br/>}</pre> | no |
15+
| <a name="input_detectors"></a> [detectors](#input\_detectors) | The configuration for the GuardDuty detectors | <pre>map(object({<br/> name = string<br/> # The name of the detector<br/> auto_enable = optional(string, "NONE")<br/> # The frequency of finding publishing<br/> eks_additional_configuration = optional(map(object({<br/> auto_enable = optional(string, "NONE")<br/> # The status of the additional configuration<br/> })), {})<br/> ecs_additional_configuration = optional(map(object({<br/> auto_enable = optional(string, "NONE")<br/> # The status of the additional configuration<br/> })), {})<br/> ec2_additional_configuration = optional(map(object({<br/> auto_enable = optional(string, "NONE")<br/> # The status of the additional configuration<br/> })), {})<br/> }))</pre> | <pre>{<br/> "eks": {<br/> "auto_enable": "ALL",<br/> "name": "EKS_AUDIT_LOGS"<br/> },<br/> "eks_runtime_monitoring": {<br/> "auto_enable": "NONE",<br/> "eks_additional_configuration": {<br/> "EKS_ADDON_MANAGEMENT": {<br/> "auto_enable": "NONE"<br/> }<br/> },<br/> "name": "EKS_RUNTIME_MONITORING"<br/> },<br/> "lambda": {<br/> "auto_enable": "NONE",<br/> "name": "LAMBDA_NETWORK_LOGS"<br/> },<br/> "malware": {<br/> "auto_enable": "NONE",<br/> "name": "EBS_MALWARE_PROTECTION"<br/> },<br/> "rds": {<br/> "auto_enable": "NONE",<br/> "name": "RDS_LOGIN_EVENTS"<br/> },<br/> "runtime_monitoring": {<br/> "auto_enable": "NONE",<br/> "ec2_additional_configuration": {<br/> "EC2_AGENT_MANAGEMENT": {<br/> "auto_enable": "NONE"<br/> }<br/> },<br/> "ecs_additional_configuration": {<br/> "ECS_FARGATE_AGENT_MANAGEMENT": {<br/> "auto_enable": "NONE"<br/> }<br/> },<br/> "eks_additional_configuration": {<br/> "EKS_ADDON_MANAGEMENT": {<br/> "auto_enable": "NONE"<br/> }<br/> },<br/> "name": "RUNTIME_MONITORING"<br/> },<br/> "s3": {<br/> "auto_enable": "NONE",<br/> "name": "S3_DATA_EVENTS"<br/> }<br/>}</pre> | no |
1616
| <a name="input_finding_publishing_frequency"></a> [finding\_publishing\_frequency](#input\_finding\_publishing\_frequency) | The frequency of finding publishing | `string` | `"FIFTEEN_MINUTES"` | no |
1717
| <a name="input_guardduty_detector_id"></a> [guardduty\_detector\_id](#input\_guardduty\_detector\_id) | Used when not creating a new detector | `string` | `null` | no |
1818

notifications.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ resource "aws_cloudwatch_event_rule" "securityhub_findings" {
4646
count = var.securityhub.notifications.enable ? 1 : 0
4747

4848
name = var.securityhub.notifications.eventbridge_rule_name
49-
description = format("Capture Security Hub findings and publish to the SNS topic: %s", try(module.securityhub_notifications[0].sns_topic_name, null))
49+
description = format("Capture Security Hub findings and publish to the SNS topic: %s", var.securityhub.notifications.sns_topic_queue_name)
5050
event_pattern = local.securityhub_event_pattern
5151
tags = local.tags
52+
53+
depends_on = [
54+
module.securityhub_notifications
55+
]
5256
}
5357

5458
## Add the SNS Topic as a Target for the EventBridge Rule

variables.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@ variable "config" {
3333
}
3434
}
3535

36+
variable "inspector" {
37+
description = "Organizational configuration for the AWS Inspector service"
38+
type = object({
39+
account_id = optional(string, null)
40+
# The delegated administrator account ID for the AWS Inspector service
41+
enable = optional(bool, false)
42+
# Indicates whether to enable the AWS Inspector service
43+
enable_ec2_scan = optional(bool, false)
44+
# Indicates whether to enable the AWS Inspector service for EC2 instances
45+
enable_ecr_scan = optional(bool, false)
46+
# Indicates whether to enable the AWS Inspector service for ECR repositories
47+
enable_lambda_scan = optional(bool, false)
48+
# Indicates whether to enable the AWS Inspector service for Lambda functions
49+
enable_lambda_code_scan = optional(bool, false)
50+
# Indicates whether to enable the AWS Inspector service for Lambda code
51+
})
52+
default = {
53+
enable = false
54+
}
55+
}
56+
3657
variable "notifications" {
3758
description = "Configuration for the notifications"
3859
type = object({

0 commit comments

Comments
 (0)