Skip to content

Instantly share code, notes, and snippets.

@ashutoshkarna03
Created May 18, 2020 17:14
Show Gist options
  • Save ashutoshkarna03/6cef24007c609b8c613fb31ecdbbee01 to your computer and use it in GitHub Desktop.
Save ashutoshkarna03/6cef24007c609b8c613fb31ecdbbee01 to your computer and use it in GitHub Desktop.
def stop_instance(instance_id, client):
waiter = client.get_waiter('instance_stopped')
# call stop_instances to stop the instance
response = client.stop_instances(InstanceIds=[instance_id], DryRun=False)
# waiter waits until the stop operation is complete
print('Stopping instance, this may take few minutes...')
waiter.wait(InstanceIds=[instance_id,], DryRun=False)
return dict(success=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment