Friday, July 29, 2011

How to find the right Ubuntu AMI with tools

A while ago, I gave instructions on how you could find the right Ubuntu AMI. I promised to write about how you could accomplished programmaticly.

When we publish Ubuntu AMIs, we simultaneously publish machine consumable data to The data there contains information so that you can:
  • Find the latest ami of a given type (hvm/ebs/instance-store), arch, and region.
  • Download the pristine image files

I think the format of the data is generally discernible, but there is some more information on the Ubuntu Wiki.

I've put an example client together. Here is some example usage:
  • Launch the latest released image in us-east-1

  • $ euca-run-instances --instance-type t1.micro --key mykey $(ubuntu-ami)
  • Open the Amazon EC2 console to launch the latest Oneiric daily build

  • You can now directly link to launching an image in Amazon EC2 console, combine that with this tool to open your browser to the right page.
    $ ami=$(ubuntu-ami us-west-1 oneiric daily i386)
    $ gnome-open${ami}

  • Download and extract the latest tarball for lucid
  • Here, 'pubname' is the recommended "publish name" of this AMI, which happens to correspond to the basename of the name on EC2, and "url" is a fully qualified url to .
    $ wget $(ubuntu-ami -f "%{url} -O %{pubname}.tar.gz")
    $ uec-publish-tarball *.tar.gz my-ubuntu-images

I don't think I'll get this into 11.10, but I'd like to have something with this function into 12.04, and support launching AMIs directly through it for ease of use. I'd love to hear input on what you'd like a "ubuntu-run-instance" command to look like and do.

1 comment:

  1. Just a follow up, we've added 'ubuntu-cloudimg-query' to oneiric's cloud-utils package. It does what 'ubuntu-ami' did and more.