I am trying to execute an SSM automation and then apply a waiter to wait for the execution to complete but i am landing on a InvocationDoesNotExist exception.
My code is as follows:
# Get the SSM client
client = boto3.client('ssm')
#Start the automation runbook and capture response
response = client.start_automation_execution(
DocumentName='document_name',
DocumentVersion='$LATEST',
Parameters={
'RestoredInstanceIds': [
'i-02fee85b181a1gb55',
]
}
)
print(response)
waiter = client.get_waiter('command_executed')
waiter.wait(
CommandId=response["AutomationExecutionId"],
InstanceId='i-02fee85b181a1gb55'
)
print("DONE")
The error is as follows: botocore.exceptions.WaiterError: Waiter CommandExecuted failed: An error occurred (InvocationDoesNotExist):
The print(response) works fine and gives me the correct execution ID:
{'AutomationExecutionId': '9a433866-...', 'ResponseMetadata': {'RequestId': '9a433866-...', 'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'Server', 'date': 'Wed, 18 Aug 2021 23:21:32 GMT', 'content-type': 'application/x-amz-json-1.1', 'content-length': '64', 'connection': 'keep-alive', 'x-amzn-requestid': '9a433866...'}, 'RetryAttempts': 0}}
Can someone please help why this is not working ?