This Terraform module configures AWS Security Hub for an AWS account or organization.
- Enables AWS Security Hub
- Configures Security Hub settings
- Allows enabling/disabling of specific security standards
- Supports subscription to additional AWS product integrations
- Supports configuration at the organization level
- Supports central configuration policies
module "securityhub" {
source = "rhythmictech/securityhub/aws"
enable_default_standards = true
control_finding_generator = "SECURITY_CONTROL"
auto_enable_controls = true
enable_cis_standard = true
enable_pci_dss_standard = true
enable_aws_foundational_standard = true
product_subscriptions = [
"aws/guardduty",
"aws/inspector",
"aws/macie"
]
}
module "securityhub" {
source = "rhythmictech/securityhub/aws"
enable_organization_config = true
admin_account_id = "123456789012"
auto_enable_new_accounts = true
auto_enable_standards_for_new_accounts = true
enable_default_standards = true
control_finding_generator = "SECURITY_CONTROL"
auto_enable_controls = true
enable_cis_standard = true
enable_pci_dss_standard = true
enable_aws_foundational_standard = true
product_subscriptions = [
"aws/guardduty",
"aws/inspector",
"aws/macie"
]
}
module "securityhub" {
source = "rhythmictech/securityhub/aws"
enable_organization_config = true
admin_account_id = "123456789012"
configuration_type_central = true
enable_default_standards = true
control_finding_generator = "SECURITY_CONTROL"
auto_enable_controls = true
enable_cis_standard = true
enable_pci_dss_standard = true
enable_aws_foundational_standard = true
product_subscriptions = [
"aws/guardduty",
"aws/inspector",
"aws/macie"
]
}
module "securityhub" {
source = "rhythmictech/securityhub/aws"
enable_organization_config = true
admin_account_id = "123456789012"
configuration_type_central = false
auto_enable_new_accounts = true
auto_enable_standards_for_new_accounts = true
enable_default_standards = true
control_finding_generator = "SECURITY_CONTROL"
auto_enable_controls = true
enable_cis_standard = true
enable_pci_dss_standard = true
enable_aws_foundational_standard = true
product_subscriptions = [
"aws/guardduty",
"aws/inspector",
"aws/macie"
]
}
module "securityhub" {
source = "rhythmictech/securityhub/aws"
enable_organization_config = true
admin_account_id = "123456789012"
configuration_type_central = true
enable_default_standards = true
control_finding_generator = "SECURITY_CONTROL"
auto_enable_controls = true
enable_cis_standard = true
enable_pci_dss_standard = true
enable_aws_foundational_standard = true
product_subscriptions = [
"aws/guardduty",
"aws/inspector",
"aws/macie"
]
central_security_controls = {
"arn:aws:securityhub:us-east-1:123456789012:control/cis-aws-foundations-benchmark/v/1.2.0/1.1" = {
enabled = false
disabled_reason = "Not applicable to our environment"
},
"arn:aws:securityhub:us-east-1:123456789012:control/cis-aws-foundations-benchmark/v/1.2.0/1.2" = {
enabled = true
disabled_reason = null
}
}
}
Example (Organization Level with CENTRAL configuration, control management, and configuration policies)
module "securityhub" {
source = "rhythmictech/securityhub/aws"
enable_organization_config = true
admin_account_id = "123456789012"
configuration_type_central = true
enable_default_standards = true
control_finding_generator = "SECURITY_CONTROL"
auto_enable_controls = true
enable_cis_standard = true
enable_pci_dss_standard = true
enable_aws_foundational_standard = true
product_subscriptions = [
"aws/guardduty",
"aws/inspector",
"aws/macie"
]
central_configuration_policies = {
"Default Policy" = {
description = "Default configuration policy for all accounts"
enabled = true
enabled_standard_arns = [
"arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/1.2.0",
"arn:aws:securityhub:${local.region}::standards/pci-dss/v/3.2.1"
]
enabled_control_identifiers = [
"CIS.1.1",
"CIS.1.2"
]
disabled_control_identifiers = [
"PCI.DSS.v3.2.1/3.4"
]
custom_parameters = [
{
security_control_id = "CIS.1.1"
parameter = {
name = "MaxPasswordAge"
value_type = "CUSTOM"
value = {
int = 60
}
}
}
]
}
}
}
- The
configuration_type_central
variable determines whether to use CENTRAL or LOCAL configuration type for organization configuration. - When
configuration_type_central
is set totrue
, bothauto_enable_new_accounts
andauto_enable_standards_for_new_accounts
must be set tofalse
. - The
central_configuration_policies
variable allows you to create and manage configuration policies when using CENTRAL configuration. Each policy can have its own settings for enabling standards, controls, and custom parameters. - The
product_subscriptions
variable accepts a list of AWS products in the format 'vendor/product'. Refer to the variable description invariables.tf
for a comprehensive list of available AWS products. - A 10-second delay is added after enabling Security Hub to ensure proper setup before subscribing to standards and products.
- When configuring at the organization level, make sure you have the necessary permissions and that your AWS Organizations setup is complete.
Name | Version |
---|---|
terraform | >= 1.1 |
aws | >= 5 |
time | ~> 0.12 |
Name | Version |
---|---|
aws | 5.66.0 |
time | 0.12.1 |
No modules.
Name | Description | Type | Default | Required |
---|---|---|---|---|
admin_account_id | AWS account ID for the Security Hub administrator account (required if enable_organization_config is true) | string |
null |
no |
auto_enable_controls | Whether to automatically enable new controls when they are added to standards that are enabled | bool |
true |
no |
auto_enable_new_accounts | Automatically enable Security Hub for new accounts added to your organization (must be false when configuration_type_central is true) | bool |
true |
no |
auto_enable_standards_for_new_accounts | Automatically enable Security Hub default standards for new accounts added to your organization (must be false when configuration_type_central is true). When true, sets auto_enable_standards to 'DEFAULT', otherwise 'NONE'. | bool |
true |
no |
central_configuration_policies | Map of configuration policies to create in central configuration | map(object({ |
{} |
no |
central_security_controls | Map of security controls to enable/disable in central configuration | map(object({ |
{} |
no |
cis_standard_version | Version of the CIS AWS Foundations Benchmark to use | string |
"3.0.0" |
no |
configuration_type_central | Whether to use CENTRAL configuration type for organization configuration | bool |
false |
no |
control_finding_generator | Updates whether the calling account has consolidated control findings turned on | string |
"SECURITY_CONTROL" |
no |
enable_aws_foundational_standard | Enable AWS Foundational Security Best Practices v1.0.0 | bool |
true |
no |
enable_cis_standard | Enable CIS AWS Foundations Benchmark | bool |
true |
no |
enable_default_standards | Whether to enable the default standards provided by Security Hub | bool |
true |
no |
enable_finding_aggregator | Whether to enable the Security Hub finding aggregator (must be true if enable_organization_config is true) | bool |
false |
no |
enable_nist_standard | Enable NIST SP 800-53 Rev. 5 standard | bool |
false |
no |
enable_organization_config | Whether to enable Security Hub configuration at the organization level | bool |
false |
no |
enable_pci_dss_standard | Enable PCI DSS v3.2.1 | bool |
false |
no |
finding_aggregator_linking_mode | Specifies the linking mode for the finding aggregator | string |
"ALL_REGIONS" |
no |
finding_aggregator_regions | List of regions to aggregate findings from when linking_mode is SPECIFIED_REGIONS | list(string) |
null |
no |
product_subscriptions | List of product subscriptions to enable in Security Hub. Format: 'vendor/product'. Available AWS products include: - aws/guardduty - aws/inspector - aws/access-analyzer - aws/macie - aws/detective - aws/health - aws/config - aws/firewall-manager - aws/systems-manager - aws/iam-access-analyzer - aws/chatbot - aws/auditmanager - aws/cloudhsm - aws/cloudsearch - aws/cloudtrail - aws/codebuild - aws/cognito-idp - aws/connect - aws/dms - aws/dynamodb - aws/ebs - aws/ec2 - aws/ecr - aws/ecs - aws/efs - aws/eks - aws/elasticache - aws/elasticbeanstalk - aws/elb - aws/es - aws/fsx - aws/kinesis - aws/lambda - aws/network-firewall - aws/opensearch - aws/rds - aws/redshift - aws/route53 - aws/s3 - aws/sagemaker - aws/secretsmanager - aws/ses - aws/shield - aws/sns - aws/sqs - aws/ssm - aws/waf For the most up-to-date and complete list, refer to AWS documentation: https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-findings-providers.html |
list(string) |
[] |
no |
No outputs.