@@ -147,14 +147,14 @@ def create_maintenance_window(params: dict, account_id: str, regions: list) -> d
147
147
return {"window1_ids" : window1_ids , "window2_ids" : window2_ids , "window3_ids" : window3_ids }
148
148
149
149
150
- def define_maintenance_window_targets (params : dict , window1_id_response : list , window2_id_response : list , window3_id_response : list , account_id : str ) -> dict :
150
+ def define_mw_targets (params : dict , window1_id_response : list , window2_id_response : list , window3_id_response : list , account_id : str ) -> dict [ str , list ]
151
151
"""Define Maintenance Window Targets.
152
152
153
153
Args:
154
154
params (dict): Cloudformation Params
155
- window1_id_response (dict ): Previous Window 1 IDs for the Targets
156
- window2_id_response (dict ): Previous Window 2 IDs for the Targets
157
- window3_id_response (dict ): Previous Window 3 IDs for the Targets
155
+ window1_id_response (list ): Previous Window 1 IDs for the Targets
156
+ window2_id_response (list ): Previous Window 2 IDs for the Targets
157
+ window3_id_response (list ): Previous Window 3 IDs for the Targets
158
158
account_id (str): Account ID for the targets to live in
159
159
160
160
Returns:
@@ -177,7 +177,7 @@ def define_maintenance_window_targets(params: dict, window1_id_response: list, w
177
177
target_description = params .get ("TARGET1_DESCRIPTION" , "" )
178
178
target_key_value_1 = params .get ("TARGET1_VALUE_1" , "" )
179
179
target_key_value_2 = params .get ("TARGET1_VALUE_2" , "" )
180
- print ("About to create window " + str (target_name ))
180
+ LOGGER . info ("About to create window " + str (target_name ))
181
181
maintenance_window_targets = ssmclient .register_target_with_maintenance_window (
182
182
Name = target_name ,
183
183
Description = target_description ,
@@ -257,13 +257,8 @@ def define_maintenance_window_targets(params: dict, window1_id_response: list, w
257
257
return {"window1_targets" : window1_targets , "window2_targets" : window2_targets , "window3_targets" : window3_targets }
258
258
259
259
260
- def define_maintenance_window_tasks (
261
- params : dict ,
262
- window_id_response : dict ,
263
- window_target_response : dict ,
264
- account_id : str ,
265
- ) -> dict :
266
- """Define maintenance window targets.
260
+ def def_mw_tasks ( params : dict , window_id_response : dict , window_target_response : dict , account_id : str ) -> dict : # noqa: CFQ001
261
+ """Define maintenance window tasks.
267
262
268
263
Args:
269
264
params (dict): Parameters CFN
@@ -293,7 +288,6 @@ def define_maintenance_window_tasks(
293
288
task_operation = params .get ("TASK1_OPERATION" , "Scan" )
294
289
task_rebootoption = params .get ("TASK1_REBOOTOPTION" , "NoReboot" )
295
290
296
-
297
291
for response2 in window_target_response ['window1_targets' ]:
298
292
LOGGER .info (response2 )
299
293
if (
@@ -468,7 +462,7 @@ def parameter_pattern_validator(parameter_name: str, parameter_value: str, patte
468
462
469
463
def get_validated_parameters (
470
464
event : CloudFormationCustomResourceEvent ,
471
- ) -> dict : # noqa: CCR001 (cognitive complexity)
465
+ ) - > dict : # noqa: CCR001 (cognitive complexity), CFQ001
472
466
"""Validate AWS CloudFormation parameters.
473
467
474
468
Args:
@@ -703,9 +697,14 @@ def process_create_update_event(params: dict, regions: list) -> Dict:
703
697
all_window_ids .append (window_ids_raw ["window1_ids" ])
704
698
all_window_ids .append (window_ids_raw ["window2_ids" ])
705
699
all_window_ids .append (window_ids_raw ["window3_ids" ])
706
- window_target_response = define_maintenance_window_targets (params , window_ids_raw ["window1_ids" ],window_ids_raw ["window2_ids" ],window_ids_raw ["window3_ids" ], account_id )
700
+ window_target_response = define_mw_targets (
701
+ params ,
702
+ window_ids_raw ["window1_ids" ],
703
+ window_ids_raw ["window2_ids" ],
704
+ window_ids_raw ["window3_ids" ],
705
+ account_id )
707
706
all_window_targets .append (window_target_response )
708
- all_window_tasks .append (define_maintenance_window_tasks (params , window_ids_raw , window_target_response , account_id ))
707
+ all_window_tasks .append (def_mw_tasks (params , window_ids_raw , window_target_response , account_id ))
709
708
return {"window_ids" : all_window_ids , "window_targets" : all_window_targets , "window_tasks" : all_window_tasks }
710
709
711
710
@@ -722,7 +721,7 @@ def process_cloudformation_event(event: CloudFormationCustomResourceEvent, conte
722
721
Returns:
723
722
AWS CloudFormation physical resource id
724
723
"""
725
- request_type = event ["RequestType" ]
724
+ request_type = event ["RequestType" ]
726
725
LOGGER .info (f"{ request_type } Event" )
727
726
LOGGER .debug (f"Lambda Context: { context } " )
728
727
0 commit comments