ec2.Waiter.ImageAvailable doesn't wait till image state is "available"
See original GitHub issueec2.Waiter.ImageAvailable doesn’t wait till image state is “available”
for image in images['Images']:
print("building image for %s" % image['Name'])
instance = buildinstance(SharedServicesCreds, image)
instance[0].wait_until_running()
pp.pprint(instance[0].launch_time)
newimage = instance[0].create_image(Name=image['Name'])
pp.pprint(newimage.state)
# wait_until_exits only checks that the image exists not that it is in state available
newimage.wait_until_exists()
waiter = sharedservicesec2client.get_waiter('image_available')
waiter.wait(ImageIds=[ newimage.image_id ])
pp.pprint(newimage.state)
building image for MY-RHEL7-INSTANCE datetime.datetime(2017, 8, 18, 17, 24, 43, tzinfo=tzutc()) ‘pending’ ‘pending’
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
AWS boto3 image waiter is not working properly
1. We need more detail about what "doesn't work" means. Is the image available, but it's in pending state? · Image state is...
Read more >image-available — AWS CLI 1.27.29 Command Reference
Wait until JMESPath query Images[].State returns available for all elements when polling with describe-images .
Read more >EC2 — Boto3 Docs 1.26.32 documentation - AWS
Amazon Elastic Block Store (Amazon EBS) provides block level storage volumes for use with EC2 instances. EBS volumes are highly available and reliable ......
Read more >Working with EC2 Instances using Boto3 in Python
MaxCount – maximum number of EC2 instances to launch; ImageId – the Amazon Machine Image, which is used to launch your EC2 instance...
Read more >Amazon AMI - Builders | Packer - HashiCorp Developer
Works similarly to the chroot builder but does not require running in AWS. ... easier to use and Amazon generally recommends EBS-backed images...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll just leave it here… not sure if this has been added recently, or always been there, but instead of the empty
.wait_until_exists()
, you can pass in a filter to it:and it will return only after your image state has changed to
available
.My previous statement was only half correct, my apologies. While it is true that the waiter accessed via a boto3 resource will not refresh the resource, it does clear the cached data. This means that the next attempt to access an attribute on the resource will force it to be hydrated again. Thus the difference in behavior here ultimately comes down to accessing the waiter via a
boto3.Resource
or directly frombotocore
. Adding the waiter you’re using to the resource definition may be one route to make the behavior consistent. As a workaround for now you could manually refresh your resource after the waiter has ended.We need to add the
image_available
waiter to the image resource.