简体   繁体   中英

BOTO3 Waiter Types for SSM

Does anyone know the available waiter types for SSM? The BOTO3 documentation is missing a section. It says "See the waiters section" , but there is no such a section.

Googling online didn't help much, as it's not a common topic at all.

You can verify this as follows:

ssm = boto3.client('ssm')

print(ssm.waiter_names) 

This will print out empty array:

[]

For comparison, for ec2 :

ec2 = boto3.client('ec2')

print(ec2.waiter_names)

Will give (not all shown):

['export_task_completed',
 'image_available',
 'image_exists',
 'instance_exists',
 'instance_running',
 'instance_status_ok',
 'instance_stopped',
 'subnet_available',
 'system_status_ok',
 'volume_available',
 'volume_deleted',
 'volume_in_use',
 'vpc_available',
 'vpc_exists',
 'vpc_peering_connection_deleted',
 'vpc_peering_connection_exists',
 'vpn_connection_available',
 'vpn_connection_deleted']

get_waiter method is probably inherited from some parent class.

Here's a homegrown waiter you can try:

def send_command_wait_for_succes(commandid, instanceid):
    '''wait for success status, or end after 2 minutes'''
    cnt = 0
    while True:
        response = ssm_client.get_command_invocation(
            CommandId=commandid,
            InstanceId=instanceid)
        if response['Status'] != 'Success':
             time.sleep(5)
             cnt = cnt + 1
             if cnt == 24:
                return False
                break
        else:
            return True
            break

print(send_command_wait_for_succes(commandid, instanceid))

Currently there's only a command_executed waiter.

From the boto3 docs :

import boto3

client = boto3.client('ssm')
waiter = client.get_waiter('command_executed')
waiter.wait(
    CommandId='string',
    InstanceId='string',
    PluginName='string',
    WaiterConfig={
        'Delay': 123,
        'MaxAttempts': 123
    }
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM