@@ -82,6 +82,7 @@ def run_scenario(self):
8282 self .ou_id = sandbox_ou_id
8383
8484 # List and Enable Baseline.
85+ print ("\n Managing Baselines:" )
8586 control_tower_baseline = None
8687 identity_center_baseline = None
8788 baselines = self .controltower_wrapper .list_baselines ()
@@ -93,9 +94,7 @@ def run_scenario(self):
9394
9495 if self .use_landing_zone :
9596 print ("\n Listing enabled baselines:" )
96- enabled_baselines = self .controltower_wrapper .list_enabled_baselines (
97- self .ou_arn
98- )
97+ enabled_baselines = self .controltower_wrapper .list_enabled_baselines ()
9998 for baseline in enabled_baselines :
10099 # If the Identity Center baseline is enabled, the identifier must be used for other baselines.
101100 if 'baseline/LN25R72TTG6IGPTQ' in baseline ['baselineIdentifier' ]:
@@ -107,25 +106,27 @@ def run_scenario(self):
107106 q .is_yesno ,
108107 ):
109108 print ("\n Enabling Control Tower Baseline." )
109+ ic_baseline_arn = identity_center_baseline ['arn' ] if identity_center_baseline else None
110110 baseline_arn = self .controltower_wrapper .enable_baseline (
111111 self .ou_arn ,
112- identity_center_baseline [ 'arn' ] ,
112+ ic_baseline_arn ,
113113 control_tower_baseline ['arn' ],
114114 '4.0'
115115 )
116116 if baseline_arn :
117117 print (f"Enabled baseline ARN: { baseline_arn } " )
118118 else :
119+ # Find the enabled baseline so we can reset it.
119120 for enabled_baseline in enabled_baselines :
120- if enabled_baseline ['arn ' ] == control_tower_baseline ['arn' ]:
121- control_tower_baseline = baseline
121+ if enabled_baseline ['baselineIdentifier ' ] == control_tower_baseline ['arn' ]:
122+ baseline_arn = enabled_baseline [ 'arn' ]
122123 print ("No change, the selected baseline was already enabled." )
123124
124125 if q .ask (
125126 f"Do you want to reset the Control Tower Baseline? (y/n) " ,
126127 q .is_yesno ,
127128 ):
128- print ("\n Resetting Control Tower Baseline." )
129+ print (f "\n Resetting Control Tower Baseline. { baseline_arn } " )
129130 operation_id = self .controltower_wrapper .reset_enabled_baseline (
130131 baseline_arn
131132 )
@@ -142,23 +143,22 @@ def run_scenario(self):
142143 print (f"\n Disabled baseline operation id { operation_id } ." )
143144
144145 # List and Enable Controls.
145- print ("Managing Controls:" )
146+ print ("\n Managing Controls:" )
146147 controls = self .controltower_wrapper .list_controls ()
147148 print ("\n Listing first 5 available Controls:" )
148149 for i , control in enumerate (controls [:5 ], 1 ):
149- print (f"{ i } . { control ['Name' ]} " )
150+ print (f"{ i } . { control ['Name' ]} - { control [ 'Arn' ] } " )
150151
151152 if self .use_landing_zone :
152-
153- enabled_controls = self .controltower_wrapper .list_enabled_controls ()
153+ target_ou = self . ou_arn
154+ enabled_controls = self .controltower_wrapper .list_enabled_controls (target_ou )
154155 print ("\n Listing enabled controls:" )
155- for i , control in enabled_controls :
156- print (f"{ i } . { control ['Name ' ]} " )
156+ for i , control in enumerate ( enabled_controls , 1 ) :
157+ print (f"{ i } . { control ['controlIdentifier ' ]} " )
157158
158159 # Enable first non-enabled control as an example.
159- enabled_control_arns = [control ['Arn ' ] for control in enabled_controls ]
160+ enabled_control_arns = [control ['arn ' ] for control in enabled_controls ]
160161 control_arn = next (control ['Arn' ] for control in controls if control ['Arn' ] not in enabled_control_arns )
161- target_ou = self .ou_arn
162162
163163 if control_arn and q .ask (
164164 f"Do you want to enable the control { control_arn } ? (y/n) " ,
@@ -182,10 +182,10 @@ def run_scenario(self):
182182 control_arn , target_ou )
183183 print (f"Disable operation ID: { operation_id } " )
184184
185- print ("This concludes the control tower scenario." )
185+ print ("\n This concludes the example scenario." )
186186
187- print ("Thanks for watching!" )
188- print ("-" * 88 )
187+ print ("Thanks for watching!" )
188+ print ("-" * 88 )
189189
190190 def setup_organization (self ):
191191 """
0 commit comments