in lambda_backup.py [0:0]
def send_command(instance_id):
# Until the document is not ready, waits in accordance to a backoff mechanism.
while True:
timewait = 1
response = list_document()
if any(response[RESPONSE_DOCUMENT_KEY]):
break
time.sleep(timewait)
timewait += timewait
try:
response = ssm_client.send_command(
InstanceIds = [ instance_id ],
DocumentName = DOCUMENT_NAME,
TimeoutSeconds = 120
)
if check_response(response):
logger.info("Command sent: %s", response)
return response['Command']['CommandId']
else:
logger.error("Command could not be sent: %s", response)
return None
except Exception, e:
logger.error("Command could not be sent: %s", str(e))
return None