How to use register_task_with_maintenance_window method in localstack

Best Python code snippet using localstack_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...109 Task_ID = 'None'110 return Task_ID111def RegisterTask(ssm, Window_ID, task_name, mw_targets, s3_bucket, s3_folder):112 try:113 ssm.register_task_with_maintenance_window(114 Name = task_name,115 WindowId = Window_ID,116 Targets=[117 {118 'Key': 'WindowTargetIds',119 'Values': mw_targets120 }121 ],122 TaskArn='AWS-RunPatchBaseline',123 TaskType='RUN_COMMAND',124 MaxConcurrency='50',125 MaxErrors='50',126 Priority=1,127 TaskInvocationParameters={128 'RunCommand': {129 'OutputS3BucketName': s3_bucket,130 'OutputS3KeyPrefix': s3_folder,131 'Parameters': {132 'Operation': [133 'Install'134 ]135 }136 }137 }138 )139 print("Register Install_Patch task with Maintenance Window %s successfully!" %Window_ID)140 except:141 print("Register Install_Patch task with Maintenance Window %s failed!" %Window_ID)142 e = sys.exc_info()[1]143 print("%s" %e)144 145def UpdateTask(ssm, Window_ID, Task_ID, task_name, mw_targets, s3_bucket, s3_folder):146 try:147 ssm.update_maintenance_window_task(148 WindowId = Window_ID,149 WindowTaskId = Task_ID,150 Name=task_name,151 Targets=[152 {153 'Key': 'WindowTargetIds',154 'Values': mw_targets155 }156 ],157 TaskArn='AWS-RunPatchBaseline',158 MaxConcurrency='50',159 MaxErrors='50',160 Priority=1,161 TaskInvocationParameters={162 'RunCommand': {163 'OutputS3BucketName': s3_bucket,164 'OutputS3KeyPrefix': s3_folder,165 'Parameters': {166 'Operation': [167 'Install'168 ]169 }170 }171 }172 )173 print("Install_Patch task already exist and update successfully! MW_TASK ID is %s." %Task_ID)174 except:175 print("Install_Patch task already exist but update failed! MW_TASK ID is %s." %Task_ID)176 e=sys.exc_info()[1]177 print("%s" %e)178def RegisterLinuxRunCMD(ssm, Window_ID, task_name, mw_targets, s3_bucket, s3_folder, cmd):179 try:180 ssm.register_task_with_maintenance_window(181 Name = task_name,182 WindowId = Window_ID,183 Targets=[184 {185 'Key': 'WindowTargetIds',186 'Values': mw_targets187 }188 ],189 TaskArn='AWS-RunShellScript',190 TaskType='RUN_COMMAND',191 MaxConcurrency='50',192 MaxErrors='50',193 Priority=5,194 TaskInvocationParameters={...

Full Screen

Full Screen

maintenance_window_creation.py

Source:maintenance_window_creation.py Github

copy

Full Screen

...74 "patching_operation": self.patching_operation,75 "operation_post_patching": self.operation_post_patching,76 "run_patch_baseline_install_override_list": "" 77 }78 response = self.ssm_client.register_task_with_maintenance_window(79 WindowId=window_id,80 TaskArn=self.lambda_arn,81 ServiceRoleArn=self.service_role_arn,82 TaskType='LAMBDA',83 TaskInvocationParameters={84 'Lambda': {85 'Payload': json.dumps(payload)86 }87 })88 if self.include_asg == 'Yes':89 asg_payload = {90 "env": self.env,91 "include_asg": self.include_asg,92 "retain_healthy_percentage": self.retain_healthy_percentage,93 "refresh_asg_instances": self.refresh_asg_instances,94 "patching_operation": self.patching_operation,95 "operation_post_patching": self.operation_post_patching,96 "run_patch_baseline_install_override_list": "" 97 }98 response = self.ssm_client.register_task_with_maintenance_window(99 WindowId=window_id,100 TaskArn=self.asg_lambda_arn,101 ServiceRoleArn=self.service_role_arn,102 TaskType='LAMBDA',103 TaskInvocationParameters={104 'Lambda': {105 'Payload': json.dumps(asg_payload)106 }107 })108 109 status = "SUCCESS"110 return status, window_id 111 except Exception as exp: 112 status = "FAILED"...

Full Screen

Full Screen

patchbaseline-datasource.py

Source:patchbaseline-datasource.py Github

copy

Full Screen

...112 BaselineId='string',113 PatchGroup='string'114)115# =============================register_task_with_maintenance_window========================================116response = client.register_task_with_maintenance_window(117 WindowId='string',118 Targets=[119 {120 'Key': 'string',121 'Values': [122 'string',123 ]124 },125 ],126 TaskArn='string',127 ServiceRoleArn='string',128 TaskType='RUN_COMMAND'|'AUTOMATION'|'STEP_FUNCTIONS'|'LAMBDA',129 TaskParameters={130 'string': {...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful