Skip to content

Commit 0c0a53f

Browse files
committed
feat: feature organization setup
1 parent ec1ed8e commit 0c0a53f

File tree

3 files changed

+74
-22
lines changed

3 files changed

+74
-22
lines changed

_example/example.tf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ module "security-hub" {
1010

1111
#member account add
1212
enable_member_account = true
13-
member_account_id = "123344847783"
14-
member_mail_id = "[email protected]"
13+
member_details = [
14+
{
15+
account_id = "560633484280"
16+
mail_id = "[email protected]"
17+
invite = true
18+
},
19+
{
20+
account_id = "1122334455"
21+
mail_id = "[email protected]"
22+
invite = true
23+
}
24+
]
1525

1626
#standards
1727
enabled_standards = [
1828
"standards/aws-foundational-security-best-practices/v/1.0.0",
1929
"ruleset/cis-aws-foundations-benchmark/v/1.2.0"
2030
]
31+
2132
#products
2233
enabled_products = [
2334
"product/aws/guardduty",

main.tf

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ locals {
1414
}
1515

1616
resource "aws_securityhub_account" "security_hub" {
17-
count = var.security_hub_enabled && var.enable ? 1 : 0
17+
count = var.security_hub_enabled && var.enable ? 1 : 0
18+
enable_default_standards = var.enable_default_standards
19+
control_finding_generator = var.control_finding_generator
20+
auto_enable_controls = var.auto_enable_controls
1821
}
1922

2023
resource "aws_securityhub_standards_subscription" "standards" {
@@ -31,10 +34,12 @@ resource "aws_securityhub_product_subscription" "products" {
3134

3235
# To enable add member account to security-hub.
3336
resource "aws_securityhub_member" "example" {
34-
count = var.enable_member_account && var.enable ? 1 : 0
37+
for_each = { for member in var.member_details : member.account_id => member }
38+
account_id = each.value.account_id
39+
email = each.value.mail_id
40+
invite = each.value.invite
3541

36-
depends_on = [aws_securityhub_account.security_hub]
37-
account_id = var.member_account_id
38-
email = var.member_mail_id
39-
invite = true
42+
depends_on = [
43+
aws_securityhub_account.security_hub
44+
]
4045
}

variables.tf

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
variable "enable_organization" {
2+
description = "To enable the delagated feature for the organization."
3+
type = bool
4+
default = false
5+
}
6+
7+
variable "delegated_account_id" {
8+
description = "Acconut id of the dalegated user."
9+
type = string
10+
default = null
11+
}
12+
13+
variable "enable_default_standards" {
14+
description = "Flag to indicate whether default standards should be enabled"
15+
type = bool
16+
default = true
17+
}
18+
19+
variable "control_finding_generator" {
20+
description = <<-DOC
21+
Updates whether the calling account has consolidated control findings turned on.
22+
If the value for this field is set to SECURITY_CONTROL,
23+
Security Hub generates a single finding for a control check even when the check applies to multiple enabled standards.
24+
If the value for this field is set to STANDARD_CONTROL,
25+
Security Hub generates separate findings for a control check when the check applies to multiple enabled standards.
26+
For accounts that are part of an organization,
27+
this value can only be updated in the administrator account.
28+
DOC
29+
type = string
30+
default = null
31+
}
32+
33+
variable "auto_enable_controls" {
34+
description = <<-DOC
35+
Whether to automatically enable new controls when they are added to standards that are enabled.
36+
By default, this is set to true, and new controls are enabled automatically.
37+
To not automatically enable new controls, set this to false.
38+
DOC
39+
type = bool
40+
default = true
41+
}
42+
143
variable "enabled_standards" {
244
description = <<-DOC
345
The possible values are:
@@ -25,25 +67,20 @@ variable "security_hub_enabled" {
2567
default = true
2668
description = "To Enable seucirty-hub in aws account"
2769
}
28-
variable "member_account_id" {
29-
type = string
30-
default = ""
31-
description = "The ID of the member AWS account."
32-
}
3370

34-
variable "member_mail_id" {
35-
type = string
36-
default = ""
37-
description = "The email of the member AWS account."
71+
variable "member_details" {
72+
type = list(object({
73+
account_id = string
74+
mail_id = string
75+
invite = bool
76+
}))
77+
default = []
3878
}
3979

4080
variable "enable_member_account" {
4181
type = bool
4282
default = false
4383
description = "To create member account "
44-
45-
46-
4784
}
4885

4986
variable "enable" {
@@ -53,7 +90,6 @@ variable "enable" {
5390
}
5491

5592
variable "name" {
56-
type = string
93+
type = string
5794
default = ""
58-
5995
}

0 commit comments

Comments
 (0)