Skip to content

Commit b23355d

Browse files
author
grothja
authored
Merge pull request #4 from venkyio/main
add exclude rule packs Sorry for the long delay, thanks for the PR!
2 parents 610bc07 + d69c2c9 commit b23355d

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

examples/complete/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ module "managed_rules" {
1313
"Operational-Best-Practices-for-NIST-800-53-rev-4",
1414
]
1515

16+
rule_packs_to_exclude = [
17+
"Operational-Best-Practices-for-CIS-AWS-v1.4-Level1",
18+
"Operational-Best-Practices-for-CIS-AWS-v1.4-Level2",
19+
]
20+
21+
1622
# Extra rules not included in the Packs you want to deploy
1723
rules_to_include = [
1824
"dax-encryption-enabled",
@@ -35,4 +41,4 @@ module "managed_rules" {
3541
}
3642
}
3743
}
38-
}
44+
}

locals.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ locals {
66
local.pack_file["packs"][pack]
77
]
88

9+
rule_packs_to_exclude = [
10+
for pack in var.rule_packs_to_exclude :
11+
local.pack_file["packs"][pack]
12+
]
13+
914
rules_collected = sort(
1015
distinct(
1116
flatten(
@@ -17,9 +22,20 @@ locals {
1722
)
1823
)
1924

25+
rules_exclude_collected = sort(
26+
distinct(
27+
flatten(
28+
concat(
29+
var.rules_to_exclude,
30+
local.rule_packs_to_exclude
31+
)
32+
)
33+
)
34+
)
35+
2036
final_rules = [
2137
for rule in local.rules_collected :
22-
rule if !contains(var.rules_to_exclude, rule)
38+
rule if !contains(local.rules_exclude_collected, rule)
2339
]
2440

2541
final_managed_rules = merge(local.managed_rules, var.rule_overrides)

variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ variable "rule_packs" {
1919
type = list(string)
2020
}
2121

22+
# In cases where rules from other packs overlap and let's say we want to exclude all overlap rules from a pack..
23+
# this feature should address that. Example use case is where securityhub deploys CIS Level1 and 2 Rules and
24+
# lets say we want to exclude all these rules from NIST pack
25+
variable "rule_packs_to_exclude" {
26+
description = "A list of Rule Packs (based off AWS Conformance Packs) from which overlap rules to exclude"
27+
default = []
28+
type = list(string)
29+
}
30+
2231
variable "rules_to_exclude" {
2332
description = "A list of individual AWS-managed Config Rules to exclude from deployment"
2433
default = []

0 commit comments

Comments
 (0)