Packer: AMI isn't available immediately after the packer is done on AWS

Created on 17 Mar 2017  ยท  4Comments  ยท  Source: hashicorp/packer

I am using latest packer for OS X with "amazon-ebs" builder.

I do packer build . It builds and creates AMI. However, I noticed that it may be unavailable on AWS console for another minute or so (which creates some confusion).

It looks like while it's doing "amazon-ebs: Waiting for AMI to become ready..." packer exits prematurely.

I am pretty sure that AWS API returns that AMI is ready. However, I wonder whether there is a better way to check whether AMI is available through all AWS facilities (including UI).

buildeamazon question

Most helpful comment

I know this is an old thread, but since it's one of the first things that comes up when you google this issue.
I've found this little powershell command quite useful.
PreReqs: Install AWSCLI, and know your ami-id & region.

(aws ec2 describe-images --image-ids [YOUR AMI-ID] --region [AMI REGION] | ConvertFrom-Json | sel
ect -expand Images | Select -ExpandProperty state | Out-String -Stream) -eq "available"

Stick it in a loop in a wait step and you're good to go!

All 4 comments

I'm afraid, since amazon only offers us eventual consistency, that there's nothing further we can do. We already wait for the image to become visible to us, and output the AMI ID, but we have no further power after that. Because of the way their API works, even if the AMI is visible to us, there's no way we can guarantee that it's visible globally.

I advise reading through this guide, and implementing their suggestion to wait using exponential back-off: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/query-api-troubleshooting.html#eventual-consistency

If you'd like help figuring out how to get your downstream services to use exponential back off, I'd be happy to help here, but I think the mailing list would be the best place to go.

got it. yeah. it totally makes sense (I wasn't aware of eventual consistency).

I know this is an old thread, but since it's one of the first things that comes up when you google this issue.
I've found this little powershell command quite useful.
PreReqs: Install AWSCLI, and know your ami-id & region.

(aws ec2 describe-images --image-ids [YOUR AMI-ID] --region [AMI REGION] | ConvertFrom-Json | sel
ect -expand Images | Select -ExpandProperty state | Out-String -Stream) -eq "available"

Stick it in a loop in a wait step and you're good to go!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jesse-c picture jesse-c  ยท  3Comments

brettswift picture brettswift  ยท  3Comments

s4mur4i picture s4mur4i  ยท  3Comments

znerd picture znerd  ยท  3Comments

Tensho picture Tensho  ยท  3Comments