what's the proper way to check if terminating AWS EC2 instance is successful using boto3?

Viewed 4374

I use the following code to terminate an aws EC2 instance. What is the proper way to check whether the termination is successful?

s = boto3.Session(profile_name='dev')
ec2 = s.resource('ec2', region_name='us-east-1')
ins = ec2.Instance(instance_id)
res = ins.terminate()

Should I check whether

res['TerminatingInstances'][0]['CurrentState']['Name']=='shutting-down'

Or ignore res and describe the instance again to check?

1 Answers
Related