AndyL
AndyL

Reputation: 14693

Download an Amazon EC2 AMI?

I would like to download a public Amazon EC2 AMI, such as this one (Ubuntu Lucid), so that I can programmatically extract its contents.

How do I do this? I suspect there is an S3 address somewhere? This blog post looks like it once described this process, but the link seems to no longer work.

So far I can only find explanations of how to move around EC2 instance within AWS. I believe manifest files are an important piece of the puzzle.

Upvotes: 45

Views: 72075

Answers (4)

Etienne Dechamps
Etienne Dechamps

Reputation: 25371

I can think of at least two approaches:

Exporting the AMI to S3

Follow the (surprisingly complicated) EC2 VM export docs to export the AMI to S3, then download from S3.

This may work for some AMIs, but sadly it didn't work for me when I tried it because I was trying to download an AMI exported from an Amazon Lightsail snapshot, which apparently fails the prerequisites:

$ aws ec2 export-image --image-id ami-xxx --disk-image-format RAW --s3-export-location S3Bucket=xxx

An error occurred (InvalidParameter) when calling the ExportImage operation: The image ID (ami-xxx) provided has encrypted EBS block devices and is not exportable.

What did work, however, was the following approach:

Attaching the volume to an EC2 instance

  1. Launch an EC2 instance from the AMI.
  2. Stop the instance and detach its volume.
  3. Attach the volume to another instance (either a new one or one you already have lying around).
  4. Connect to the instance.
  5. You can then access the volume from that instance and use the tools of your choice to extract its contents (e.g. mount it, inspect it, rsync from it, etc.).

Upvotes: 2

Bob
Bob

Reputation: 11

Seems an approach would be to create a volume directly from the public ami. Then you could run an instance, mount the volume you created from the ami, and download the files from the instance using any file transfer scheme.

Upvotes: -1

ken
ken

Reputation: 1097

Use the ec2-download-bundle in the AMI Tools to download AMIs. Create an instance, then immediately create an AMI. Use ec2-download-bundle to retrieve and decrypt the AMI.

Upvotes: 7

Anon
Anon

Reputation: 73

Is there a real problem that you're trying to solve?

Because if there is, and you need the contents of a particular AMI to solve it, then your best approach is going to be starting an instance and taking a snapshot of its running EBS (which you can then download). If you're not using an EBS-backed instance, then you can use the Amazon tools to create an AMI from your current instance.

Upvotes: -3

Related Questions