How can I delete an AMI?

124 views
Skip to first unread message

ripper234

unread,
Mar 15, 2011, 10:38:57 AM3/15/11
to boto-...@googlegroups.com
Given an image ID, how can I delete it using boto?

Jeff Bauer

unread,
Mar 15, 2011, 11:18:14 AM3/15/11
to boto-...@googlegroups.com
On Tue, Mar 15, 2011 at 07:38:57AM -0700, ripper234 wrote:
> Given an image ID, how can I delete it using boto?

deregister_image(image_id)

Jeff Bauer
Rubicon, Inc.

gaurav gehlot

unread,
Mar 15, 2011, 1:12:28 PM3/15/11
to boto-...@googlegroups.com
As you already have the image ID you can use the code similar to the
following. amiToken is the image id in the code below -

image_to_be_deleted = conn.get_image(amiToken)
if image_to_be_deleted is not None:
snapshot_id =
image_to_be_deleted.block_device_mapping.current_value.snapshot_id
print "Deregistering the AMI image %s" % str(image_to_be_deleted)
conn.deregister_image(amiToken)
# delete the snapshot volume for this image
print "Deleting snapshot " + snapshot_id
conn.delete_snapshot(snapshot_id)
else:
print "Cannot find image %s. Please delete it manually" % amiToken

On Tue, Mar 15, 2011 at 8:08 PM, ripper234 <ron....@gmail.com> wrote:
> Given an image ID, how can I delete it using boto?
>

> --
> You received this message because you are subscribed to the Google Groups
> "boto-users" group.
> To post to this group, send email to boto-...@googlegroups.com.
> To unsubscribe from this group, send email to
> boto-users+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/boto-users?hl=en.
>

Reply all
Reply to author
Forward
0 new messages