File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
deployments/runtime/src/ou-validation-events Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -93,9 +93,12 @@ export const handler = async (input: AddScpInput) => {
9393
9494 // Find roots to attach FullAWSAccess
9595 const rootIds = await scps . organizationRoots ( ) ;
96+ const rootOus = organizationalUnits . filter ( ou => {
97+ return ! ou . ouPath . includes ( '/' ) ;
98+ } ) ;
9699
97100 // Find Accelerator accounts and OUs to attach FullAWSAccess
98- const acceleratorOuIds = organizationalUnits . map ( ou => ou . ouId ) ;
101+ const acceleratorOuIds = rootOus . map ( ou => ou . ouId ) ;
99102 const acceleratorAccountIds = accounts . map ( a => a . id ) ;
100103 const acceleratorTargetIds = [ ...rootIds , ...acceleratorOuIds , ...acceleratorAccountIds ] ;
101104 const acceleratorTargetOuIds = [ ...rootIds , ...acceleratorOuIds ] ;
Original file line number Diff line number Diff line change @@ -110,11 +110,16 @@ export const handler = async (input: ScheduledEvent) => {
110110 if ( ignoredOus . length > 0 ) {
111111 if ( targetId . startsWith ( 'ou-' ) ) {
112112 const destinationOrg = await organizations . getOrganizationalUnitWithPath ( targetId ) ;
113+ console . log ( JSON . stringify ( destinationOrg , null , 2 ) ) ;
113114 const destinationRootOrg = destinationOrg . Name ! ;
114115 if ( ignoredOus . includes ( destinationRootOrg ) ) {
115116 console . log ( `${ eventName } is on ignored-ou from ROOT, no need to reattach` ) ;
116117 return 'IGNORE' ;
117118 }
119+ if ( destinationOrg . Path . includes ( '/' ) ) {
120+ console . log ( `${ destinationOrg . Path } is a nested OU under ${ destinationOrg . Name } . Ignoring` ) ;
121+ return 'IGNORE' ;
122+ }
118123 } else {
119124 const accountObject = accounts . find ( acc => acc . accountId === targetId ) ;
120125 if ( ignoredOus . includes ( accountObject ?. organizationalUnit ! ) ) {
You can’t perform that action at this time.
0 commit comments