@@ -9,10 +9,10 @@ data "aws_organizations_organization" "org" {
99locals  {
1010  #  check if both old and new org parameters are provided, we fail early
1111  both_org_configuration_params  =   var. is_organizational  &&  length (var. org_units ) >  0  &&  (
12-   length (var. include_ouids ) >  0  || 
13-   length (var. exclude_ouids ) >  0  || 
14-   length (var. include_accounts ) >  0  || 
15-   length (var. exclude_accounts ) >  0 
12+      length (var. include_ouids ) >  0  || 
13+      length (var. exclude_ouids ) >  0  || 
14+      length (var. include_accounts ) >  0  || 
15+      length (var. exclude_accounts ) >  0 
1616  )
1717
1818  #  check if old org_units parameter is provided, for backwards compatibility we will always give preference to it
@@ -25,14 +25,14 @@ locals {
2525
2626check  "validate_org_configuration_params"  {
2727  assert  {
28-     condition      =  length (var. org_units ) ==  0    #  if this condition is false we throw warning
28+     condition      =  length (var. org_units ) ==  0  #  if this condition is false we throw warning
2929    error_message  =  <<- EOT 
3030    WARNING: TO BE DEPRECATED 'org_units' on 30th November, 2025. Please work with Sysdig to migrate your Terraform installs to use 'include_ouids' instead. 
3131    EOT 
3232  }
3333
3434  assert  {
35-     condition      =  ! local. both_org_configuration_params    #  if this condition is false we throw error
35+     condition      =  ! local. both_org_configuration_params  #  if this condition is false we throw error
3636    error_message  =  <<- EOT 
3737    ERROR: If both org_units and include_ouids/exclude_ouids/include_accounts/exclude_accounts variables are populated, 
3838    ONLY org_units will be considered. Please use only one of the two methods. 
@@ -70,19 +70,19 @@ locals {
7070    #  case1 - if old method is used where ONLY org_units is provided, use those
7171    local. check_old_ouid_param  ?  (
7272      " old_ouid_param" 
73-     ) :  (
73+        ) :  (
7474      #  case2 - if no include/exclude ous provided, include entire org
7575      var. is_organizational  &&  length (var. include_ouids ) ==  0  &&  length (var. exclude_ouids ) ==  0  ?  (
7676        " entire_org" 
77-       ) :  (
77+          ) :  (
7878        #  case3 - if only included ouids provided, include those ous only
7979        var. is_organizational  &&  length (var. include_ouids ) >  0  &&  length (var. exclude_ouids ) ==  0  ?  (
8080          " included_ous_only" 
81-         ) :  (
81+            ) :  (
8282          #  case4 - if only excluded ouids provided, exclude their accounts from rest of org
8383          var. is_organizational  &&  length (var. include_ouids ) ==  0  &&  length (var. exclude_ouids ) >  0  ?  (
8484            " excluded_ous_only" 
85-           ) :  (
85+              ) :  (
8686            #  case5 - if both include and exclude ouids are provided, includes override excludes
8787            var. is_organizational  &&  length (var. include_ouids ) >  0  &&  length (var. exclude_ouids ) >  0  ?  (
8888              " mixed_ous" 
@@ -99,7 +99,7 @@ locals {
9999      org_units_to_deploy =  var.org_units
100100    }
101101    entire_org =  {
102-         org_units_to_deploy =  local.root_org_unit
102+       org_units_to_deploy =  local.root_org_unit
103103    }
104104    included_ous_only =  {
105105      org_units_to_deploy =  var.include_ouids
@@ -140,15 +140,15 @@ locals {
140140    #  case1 - if old method is used where ONLY org_units is provided, this configuration is a noop
141141    local. check_old_ouid_param  ?  (
142142      " NONE" 
143-     ) :  (
143+        ) :  (
144144      #  case2 - if only included accounts provided, include those accts as well
145145      var. is_organizational  &&  length (var. include_accounts ) >  0  &&  length (var. exclude_accounts ) ==  0  ?  (
146146        " UNION" 
147-       ) :  (
147+          ) :  (
148148        #  case3 - if only excluded accounts or only excluded ouids provided, exclude those accounts
149-         var. is_organizational  &&  length (var. include_accounts ) ==  0  &&  (  length (var. exclude_accounts ) >  0  ||  local. org_configuration  ==  " excluded_ous_only"   ) ?  (
149+         var. is_organizational  &&  length (var. include_accounts ) ==  0  &&  (length (var. exclude_accounts ) >  0  ||  local. org_configuration  ==  " excluded_ous_only"  ) ?  (
150150          " DIFFERENCE" 
151-         ) :  (
151+            ) :  (
152152          #  case4 - if both include and exclude accounts are provided, includes override excludes
153153          var. is_organizational  &&  length (var. include_accounts ) >  0  &&  length (var. exclude_accounts ) >  0  ?  (
154154            " MIXED" 
@@ -158,30 +158,30 @@ locals {
158158    )
159159  )
160160
161-   ou_accounts_to_exclude  =  flatten ([  for  ou_accounts  in  data . aws_organizations_organizational_unit_descendant_accounts . ou_accounts_to_exclude :  [  ou_accounts . accounts [* ]. id  ]  ])
162-   accounts_to_exclude  =  setunion (local. ou_accounts_to_exclude , var. exclude_accounts )
161+   ou_accounts_to_exclude  =  flatten ([for  ou_accounts  in  data . aws_organizations_organizational_unit_descendant_accounts . ou_accounts_to_exclude   :  [ou_accounts . accounts [* ]. id ] ])
162+   accounts_to_exclude      =  setunion (local. ou_accounts_to_exclude , var. exclude_accounts )
163163
164164  #  switch cases for various user provided accounts configuration to be onboarded
165165  deployment_account_options  =   {
166166    NONE =  {
167-       accounts_to_deploy =  []
167+       accounts_to_deploy   =  []
168168      account_filter_type =  " NONE" 
169169    }
170170    UNION =  {
171-       accounts_to_deploy =  var.include_accounts
171+       accounts_to_deploy   =  var.include_accounts
172172      account_filter_type =  " UNION" 
173173    }
174174    DIFFERENCE =  {
175-       accounts_to_deploy =  local.accounts_to_exclude
175+       accounts_to_deploy   =  local.accounts_to_exclude
176176      account_filter_type =  " DIFFERENCE" 
177177    }
178178    MIXED =  {
179-       accounts_to_deploy =  var.include_accounts
179+       accounts_to_deploy   =  var.include_accounts
180180      account_filter_type =  " UNION" 
181181    }
182182    default =  {
183183      #  default when neither of include/exclude accounts are provided
184-       accounts_to_deploy =  []
184+       accounts_to_deploy   =  []
185185      account_filter_type =  " NONE" 
186186    }
187187  }
@@ -198,6 +198,6 @@ locals {
198198  #  XXX: due to AWS bug of not having UNION filter fully working, there is no way to add those extra accounts requested.
199199  #  to not miss out on those extra accounts, deploy the cloud resources across entire org and noop the UNION filter.
200200  #  i.e till we can't deploy UNION, we deploy it all
201-   deployment_targets_org_units  =   local. deployment_targets_accounts . account_filter_type  ==  " UNION"   ?  local. root_org_unit  :  local. deployment_targets_ous . org_units_to_deploy 
201+   deployment_targets_org_units         =   local. deployment_targets_accounts . account_filter_type  ==  " UNION"   ?  local. root_org_unit  :  local. deployment_targets_ous . org_units_to_deploy 
202202  deployment_targets_accounts_filter  =   local. deployment_targets_accounts . account_filter_type  ==  " UNION"   ?  " NONE"   :  local. deployment_targets_accounts . account_filter_type 
203- }
203+ }
0 commit comments