Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standards control feature added #114

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.0.0
current_version = 4.1.0
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
### [4.1.0](https://github.com/plus3it/terraform-aws-tardigrade-security-hub/releases/tag/4.1.0)

**Released**: 2023.06.01

**Summary**:

* Brought Standards_Controls under management to enable or disable specified controls


### [4.0.0](https://github.com/plus3it/terraform-aws-tardigrade-security-hub/releases/tag/4.0.0)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ No resources.
| <a name="input_control_finding_generator"></a> [control\_finding\_generator](#input\_control\_finding\_generator) | (Optional) Updates whether the calling account has consolidated control findings turned on. | `string` | `"SECURITY_CONTROL"` | no |
| <a name="input_product_subscription_arns"></a> [product\_subscription\_arns](#input\_product\_subscription\_arns) | List of product arns to subscribe to. See https://www.terraform.io/docs/providers/aws/r/securityhub_product_subscription.html | `list(string)` | `[]` | no |
| <a name="input_standard_subscription_arns"></a> [standard\_subscription\_arns](#input\_standard\_subscription\_arns) | List of standard arns to subscribe to. See https://www.terraform.io/docs/providers/aws/r/securityhub_standards_subscription.html | `list(string)` | `[]` | no |
| <a name="input_standards_controls"></a> [standards\_controls](#input\_standards\_controls) | List of Security Hub standards to enable or disable in current region. | <pre>list(object({<br> name = string<br> standards_control_arn = string<br> control_status = string<br> disabled_reason = string<br> }))</pre> | `[]` | no |

## Outputs

Expand Down
16 changes: 16 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ module "subscriptions" {
]
}

# Manage Control status
module "standards_controls" {
source = "./modules/standards_controls"
for_each = { for control in var.standards_controls : control.name => control }

standards_control_arn = each.value.standards_control_arn
control_status = each.value.control_status
disabled_reason = each.value.disabled_reason


depends_on = [
module.account,
module.subscriptions
johnricords marked this conversation as resolved.
Show resolved Hide resolved
]
}

# Manage action targets
module "action_targets" {
source = "./modules/action_target"
Expand Down
1 change: 1 addition & 0 deletions modules/cross-account-member/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ No resources.
| <a name="input_control_finding_generator"></a> [control\_finding\_generator](#input\_control\_finding\_generator) | (Optional) Updates whether the calling account has consolidated control findings turned on. | `string` | `"SECURITY_CONTROL"` | no |
| <a name="input_product_subscription_arns"></a> [product\_subscription\_arns](#input\_product\_subscription\_arns) | List of product arns to subscribe to. See https://www.terraform.io/docs/providers/aws/r/securityhub_product_subscription.html | `list(string)` | `[]` | no |
| <a name="input_standard_subscription_arns"></a> [standard\_subscription\_arns](#input\_standard\_subscription\_arns) | List of standard arns to subscribe to. See https://www.terraform.io/docs/providers/aws/r/securityhub_standards_subscription.html | `list(string)` | `[]` | no |
| <a name="input_standards_controls"></a> [standards\_controls](#input\_standards\_controls) | List of Security Hub standards to enable or disable in current region. | <pre>list(object({<br> name = string<br> standards_control_arn = string<br> control_status = string<br> disabled_reason = string<br> }))</pre> | `[]` | no |

## Outputs

Expand Down
1 change: 1 addition & 0 deletions modules/cross-account-member/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module "account" {
control_finding_generator = var.control_finding_generator
product_subscription_arns = var.product_subscription_arns
standard_subscription_arns = var.standard_subscription_arns
standards_controls = var.standards_controls
}

# Send invite from administrator account
Expand Down
11 changes: 11 additions & 0 deletions modules/cross-account-member/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ variable "standard_subscription_arns" {
type = list(string)
default = []
}

variable "standards_controls" {
description = "List of Security Hub standards to enable or disable in current region."
type = list(object({
name = string
standards_control_arn = string
control_status = string
disabled_reason = string
}))
default = []
}
36 changes: 36 additions & 0 deletions modules/standards_controls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# terraform-aws-tardigrade-security-hub/standards_control

<!-- BEGIN TFDOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.64.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.64.0 |

## Resources

| Name | Type |
|------|------|

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_control_status"></a> [control\_status](#input\_control\_status) | Control status enabled or disabled | `string` | n/a | yes |
| <a name="input_disabled_reason"></a> [disabled\_reason](#input\_disabled\_reason) | A description of the reason why you are disabling a security standard control | `string` | n/a | yes |
| <a name="input_standards_control_arn"></a> [standards\_control\_arn](#input\_standards\_control\_arn) | The standards control ARN | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_standards_control"></a> [standards\_control](#output\_standards\_control) | Object containing SecurityHub standards control resource |

<!-- END TFDOCS -->
5 changes: 5 additions & 0 deletions modules/standards_controls/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "aws_securityhub_standards_control" "this" {
standards_control_arn = var.standards_control_arn
control_status = var.control_status
disabled_reason = var.disabled_reason
}
4 changes: 4 additions & 0 deletions modules/standards_controls/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "standards_control" {
description = "Object containing SecurityHub standards control resource"
value = aws_securityhub_standards_control.this
}
14 changes: 14 additions & 0 deletions modules/standards_controls/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variable "standards_control_arn" {
description = "The standards control ARN"
type = string
}

variable "control_status" {
description = "Control status enabled or disabled"
type = string
}

variable "disabled_reason" {
description = "A description of the reason why you are disabling a security standard control"
type = string
}
10 changes: 10 additions & 0 deletions modules/standards_controls/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 0.13"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.64.0"
}
}
}
17 changes: 17 additions & 0 deletions tests/securityhub_cross_account/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,25 @@ module "securityhub" {
product_subscription_arns = [
"arn:aws:securityhub:us-east-1:453761072151:product/turbot/turbot",
]

standards_controls = [
{
name = "cis-aws-foundations-benchmark"
standards_control_arn = "arn:aws:securityhub:us-east-1:303523384066:control/cis-aws-foundations-benchmark/v/1.2.0/1.10"
control_status = "ENABLED"
disabled_reason = ""
},
{
name = "pci-dss"
standards_control_arn = "arn:aws:securityhub:us-east-1:303523384066:control/pci-dss/v/3.2.1/PCI.AutoScaling.1"
control_status = "DISABLED"
disabled_reason = "I don't like security"
}
]
}

output "securityhub" {
value = module.securityhub
}


16 changes: 16 additions & 0 deletions tests/securityhub_same_account/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,24 @@ module "securityhub" {
product_subscription_arns = [
"arn:aws:securityhub:us-east-1:453761072151:product/turbot/turbot",
]

standards_controls = [
{
name = "cis-aws-foundations-benchmark"
standards_control_arn = "arn:aws:securityhub:us-east-1:303523384066:control/cis-aws-foundations-benchmark/v/1.2.0/1.10"
control_status = "ENABLED"
disabled_reason = ""
},
{
name = "pci-dss"
standards_control_arn = "arn:aws:securityhub:us-east-1:303523384066:control/pci-dss/v/3.2.1/PCI.AutoScaling.1"
control_status = "DISABLED"
disabled_reason = "I don't like security"
}
]
}

output "securityhub" {
value = module.securityhub
}

11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ variable "action_targets" {
default = []
}

variable "standards_controls" {
description = "List of Security Hub standards to enable or disable in current region."
type = list(object({
name = string
standards_control_arn = string
control_status = string
disabled_reason = string
}))
default = []
}

variable "control_finding_generator" {
description = "(Optional) Updates whether the calling account has consolidated control findings turned on."
type = string
Expand Down