Best Python code snippet using localstack_python
ec2_patching_with_ssm.py
Source:ec2_patching_with_ssm.py
...57 "19-10-2021"58 ]59 })60# Get AMI creation status61response = client.describe_automation_executions(62 Filters=[63 {64 'Key': 'ExecutionId',65 'Values': [execution_response['AutomationExecutionId']]66 },67 ],68 MaxResults=50,69)70while response['AutomationExecutionMetadataList'][0]['AutomationExecutionStatus'] in ["Pending","InProgress"]:71 print("Image creation in progress")72 time.sleep(10)73 response = client.describe_automation_executions(Filters=[{'Key': 'ExecutionId','Values': [execution_response['AutomationExecutionId']]},],MaxResults=50)74if response['AutomationExecutionMetadataList'][0]['AutomationExecutionStatus'] != "Success": 75 print("Image creation failed")76else:77 print("Image creation completed")78#Patch instance79print("Patching started")80response=client.send_command(81 InstanceIds=['i-08d4c52a7c56db0bc'],82 DocumentName='AWS-RunPatchBaseline',83 DocumentVersion='$LATEST',84 TimeoutSeconds=900,85 Parameters={86 'Operation': [87 'Install'...
describe_ssm_automation_executions.py
Source:describe_ssm_automation_executions.py
...15 automation_executions_client = boto3.client('ssm', region_name = j )16 17 next_token = None18 while True:19 response1 = automation_executions_client.describe_automation_executions(20 NextToken= next_token21 ) if next_token else automation_executions_client.describe_automation_executions()22 print(response1['AutomationExecutionMetadataList']) 23 for j in response1['AutomationExecutionMetadataList']:24 25 26 print(j['AutomationExecutionId']) 27 automation_execution_id.append(j['AutomationExecutionId'])28 29 status_var = j['AutomationExecutionStatus']30 # print(status_var)31 rank = 032 if status_var == "Success":33 rank = 134 if status_var == "Failed":35 rank = 2
...
ssm_dev.py
Source:ssm_dev.py
...30 execution_id = response['AutomationExecutionId']31 32 33 while True:34 checker = client.describe_automation_executions(35 Filters=[36 {37 'Key': 'ExecutionId',38 'Values': [execution_id]39 },40 ]41 )42 checker = checker['AutomationExecutionMetadataList'][0]['AutomationExecutionStatus']43 if checker in ['InProgress','Waiting','Cancelling']:44 time.sleep(10)45 elif checker == 'Pending':46 pass47 elif checker == 'Cancelled':48 system.exit('execution stopped!')49 elif checker == 'Success':50 break51 else:52 sys.exit(0)53 54 execution_result = client.describe_automation_executions(55 Filters=[56 {57 'Key': 'ExecutionId',58 'Values': [execution_id]59 },60 ]61 )62 response = execution_result['AutomationExecutionMetadataList'][0]['Outputs']63 module.exit_json(changed=True, meta=response)64if __name__ == '__main__':...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!