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

create stackset instance for each OU separately, so that we don't recreate everything during changes #41

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 6 additions & 3 deletions modules/agentless-scanning/organizational.tf
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,15 @@ TEMPLATE

# stackset instance to deploy resources for agentless scanning, in all regions of each account in all organization units
resource "aws_cloudformation_stack_set_instance" "ou_stackset_instance" {
for_each = var.is_organizational ? local.region_set : toset([])
region = each.key
for_each = var.is_organizational ? {
for pair in setproduct(local.region_set, local.organizational_unit_ids) :
"${pair[0]}-${pair[1]}" => pair
} : {}

region = each.value[0]
stack_set_name = aws_cloudformation_stack_set.ou_resources_stackset[0].name
deployment_targets {
organizational_unit_ids = local.organizational_unit_ids
organizational_unit_ids = [each.value[1]]
}
operation_preferences {
max_concurrent_percentage = 100
Expand Down
4 changes: 2 additions & 2 deletions modules/config-posture/organizational.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ TEMPLATE
}

resource "aws_cloudformation_stack_set_instance" "stackset_instance" {
count = var.is_organizational ? 1 : 0
for_each = var.is_organizational ? toset(local.org_units_to_deploy) : []

region = var.region == "" ? null : var.region
stack_set_name = aws_cloudformation_stack_set.stackset[0].name
deployment_targets {
organizational_unit_ids = local.org_units_to_deploy
organizational_unit_ids = [each.value]
}
operation_preferences {
max_concurrent_percentage = 100
Expand Down
13 changes: 8 additions & 5 deletions modules/integrations/event-bridge/organizational.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ TEMPLATE

// stackset instance to deploy rule in all organization units
resource "aws_cloudformation_stack_set_instance" "eb_rule_stackset_instance" {
for_each = var.is_organizational ? local.region_set : toset([])
region = each.key
for_each = var.is_organizational ? {
for pair in setproduct(local.region_set, local.organizational_unit_ids) :
"${pair[0]}-${pair[1]}" => pair
} : {}

region = each.value[0]
stack_set_name = aws_cloudformation_stack_set.eb-rule-stackset[0].name
deployment_targets {
organizational_unit_ids = local.organizational_unit_ids
organizational_unit_ids = [each.value[1]]
}
operation_preferences {
max_concurrent_percentage = 100
Expand All @@ -126,11 +129,11 @@ resource "aws_cloudformation_stack_set_instance" "eb_rule_stackset_instance" {

// stackset instance to deploy role in all organization units
resource "aws_cloudformation_stack_set_instance" "eb_role_stackset_instance" {
count = var.is_organizational ? 1 : 0
for_each = var.is_organizational ? toset(local.organizational_unit_ids) : []

stack_set_name = aws_cloudformation_stack_set.eb-role-stackset[0].name
deployment_targets {
organizational_unit_ids = local.organizational_unit_ids
organizational_unit_ids = [each.value]
}
operation_preferences {
max_concurrent_percentage = 100
Expand Down
4 changes: 2 additions & 2 deletions modules/onboarding/organizational.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ TEMPLATE
}

resource "aws_cloudformation_stack_set_instance" "stackset_instance" {
count = var.is_organizational ? 1 : 0
for_each = var.is_organizational ? toset(local.org_units_to_deploy) : []

region = var.region == "" ? null : var.region
stack_set_name = aws_cloudformation_stack_set.stackset[0].name
deployment_targets {
organizational_unit_ids = local.org_units_to_deploy
organizational_unit_ids = [each.value]
}
operation_preferences {
max_concurrent_percentage = 100
Expand Down
4 changes: 2 additions & 2 deletions modules/vm-workload-scanning/organizational.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ resource "aws_cloudformation_stack_set" "scanning_role_stackset" {

# stackset instance to deploy agentless scanning role, in all organization units
resource "aws_cloudformation_stack_set_instance" "scanning_role_stackset_instance" {
count = var.is_organizational ? 1 : 0
for_each = var.is_organizational ? toset(local.organizational_unit_ids) : []

stack_set_name = aws_cloudformation_stack_set.scanning_role_stackset[0].name
deployment_targets {
organizational_unit_ids = local.organizational_unit_ids
organizational_unit_ids = [each.value]
}
operation_preferences {
max_concurrent_percentage = 100
Expand Down