The state of ec2 instance is not matched with actual.
skostrichegg opened this issue · 0 comments
Hi,
I found the state of ec2 is not matched with actual, when I entered below codes.
import boto3
rsc = boto3.resource('ec2')
a = list(rsc.instance.filter(Filters=[{'Name': 'tag:Name', 'Values': ['my_ec2_instance']}]))
a[0].state
{'Name': 'stopped', 'Code': 80}
a[0].start()
a[0].wait_until_running()
a[0].state
{'Name': 'running', 'Code': 16}
a[0].stop()
a[0].state
{'Name': 'stopping', 'Code': 64}
a[0].wait_until_stopped()
(When this blocking is released, I can check the state of EC2 is 'stopped' on AWS console page. BUT,)
a[0].state
{'Name': 'stopping', 'Code': 64}
I expected 'stopped'.
This doesn't happens every time. Sometimes it works correctly.
Could you explain me how can I fix this?
Or if something I use those API with wrong way, let me know.
My python and boto3 version is
- Python: 3.6.8
- boto3: 1.12.39
Thank you!