@@ -11,6 +11,7 @@ locals {
1111 " securityhub.amazonaws.com" ,
1212 ]
1313 regional_services = [
14+ " guardduty.amazonaws.com" ,
1415 " inspector2.amazonaws.com" ,
1516 " macie.amazonaws.com" ,
1617 ]
@@ -75,12 +76,6 @@ resource "aws_fms_admin_account" "this" {
7576 account_id = aws_organizations_account. this . id
7677}
7778
78- resource "aws_guardduty_organization_admin_account" "this" {
79- count = contains (local. delegated_service_names , " guardduty.amazonaws.com" ) ? 1 : 0
80-
81- admin_account_id = aws_organizations_account. this . id
82- }
83-
8479resource "aws_securityhub_organization_admin_account" "this" {
8580 count = contains (local. delegated_service_names , " securityhub.amazonaws.com" ) ? 1 : 0
8681
@@ -93,6 +88,20 @@ resource "aws_vpc_ipam_organization_admin_account" "this" {
9388 delegated_admin_account_id = aws_organizations_account. this . id
9489}
9590
91+ resource "aws_guardduty_organization_admin_account" "this" {
92+ for_each = toset (contains (local. delegated_service_names , " guardduty.amazonaws.com" )
93+ ? (length (local. delegated_services_map [" guardduty.amazonaws.com" ]. regions ) > 0
94+ ? local. delegated_services_map [" guardduty.amazonaws.com" ]. regions
95+ : local. all_available_regions
96+ )
97+ : []
98+ )
99+
100+ region = each. key
101+
102+ admin_account_id = aws_organizations_account. this . id
103+ }
104+
96105resource "aws_macie2_organization_admin_account" "this" {
97106 for_each = toset (contains (local. delegated_service_names , " macie.amazonaws.com" )
98107 ? (length (local. delegated_services_map [" macie.amazonaws.com" ]. regions ) > 0
0 commit comments