117

So I am having trouble working out what, specifically is the difference between these two.

As I understand it, a snapshot is simply a backup of the disk drive, whereas the AMI is a backup of the entire system (or instance I should say), but isn't the entire system technically wholly located on the disk drive? and if that's the case then there is no clear difference and I am missing something?

Melbourne2991
  • 9,735
  • 10
  • 38
  • 79

10 Answers10

73

There are two types of AMIs (and corresponding instances):

  1. instance-store (sometimes called S3-based). These are less common and I don't recommend them for beginners. An instance-store AMI is a copy of the root instance-store volume plus some metadata, all saved in an S3 bucket in a special format

  2. EBS boot. This is probably what you are using. An EBS boot AMI is an EBS snapshot of the EBS root volume plus some metadata like the architecture, kernel, AMI name, description, block device mappings, and more.

You can take a snapshot of an EBS boot volume and turn it into an EBS boot AMI by registering it with the appropriate metadata. The trickiest part of this is specifying the correct AKI id (kernel) so that it boots correctly.

Eric Hammond
  • 21,255
  • 5
  • 62
  • 72
  • Thanks eric, I backed up an AMI image, and I have the option to both launch and register it? I am confused as to what the difference is here... – Melbourne2991 Jul 13 '13 at 02:36
  • 1
    I don't know what you mean by "backed up an AMI image". – Eric Hammond Jul 13 '13 at 19:22
  • I right clicked on my instance and clicked on "create AMI" I believe. Very confused with all this terminology, apologies if I am not using it correctly – Melbourne2991 Jul 14 '13 at 06:33
  • 9
    When you click "create AMI" EC2 creates an EBS snapshot of that instance's EBS volume and registers it as an AMI. You can launch new instances specifying that AMI as the starting point. You could also create new volumes of the EBS snapshot if you just wanted to look at the files on it without running a new instance. – Eric Hammond Jul 15 '13 at 22:39
  • 6
    Alternatively, you could create an EBS snapshot of the EBS volume yourself, and then later register that snapshot as an AMI. This is a slightly more difficult way to create an AMI as it requires you to know the appropriate AMI registration attributes to set. "Create AMI" does all this for you. – Eric Hammond Jul 15 '13 at 22:41
  • Thanks Eric this is really helpful, if you don't mind me asking..I noticed all my snapshots are 8gb, however I was under the impression that after the first snapshots the others would be incremental, as in they would only contain changes that were not held in the previous snapshot, so should the snapshot size for the second..third snapshot etc be a lot smaller? – Melbourne2991 Jul 16 '13 at 00:03
  • It lists the size of the volume that was snapshotted, not the size of the snapshot being charged. – Eric Hammond Jul 16 '13 at 14:37
  • if I have an AMI, that an instance was created from it. Does the AMI include the data on that instance? I mean, if the instance contains tomcat WAR files, the the AMI that that instance was created from, includes as well? – Dejell Jun 23 '15 at 12:53
  • The EBS boot AMI snapshot contains all files on the boot disk. In fact it includes all blocks on the boot disk so deleted files are often recoverable too. – Eric Hammond Jun 29 '15 at 16:29
  • When I create an EBS AMI a snapshot is automatically created right? Then if I delete that snapshot, can I still launch an instance using that AMI? – cosbor11 Aug 08 '15 at 00:40
  • 1
    @cosbor11 You can't delete the snapshot for an AMI. – Eric Hammond Aug 09 '15 at 11:39
  • So if I backup an ec2 instance using aws backup then I don't need to backup its associated EBS root volume right? – djfm Feb 11 '20 at 10:50
  • I verified Eric's comment that you can create a AMI based on EBS snapshot. it make me understand well through hands on. https://i.stack.imgur.com/y9iNv.png – Ryan Lyu May 08 '20 at 14:39
  • @cosbor11 When I create an EBS AMI a snapshot is automatically created, then I try to delete that snapshot, the console pop up a warning "the current snapshot is currently in used by ami-xxxx". https://i.stack.imgur.com/t6Cty.png Eric is always right. – Ryan Lyu May 08 '20 at 14:43
  • @EricHammond, when I create AMI, does it contain the EBS snapshot or it is only linked to an EBS snapshot, which can be used later separately? – Jaxx Jan 08 '21 at 22:01
  • When you deregister an EBS boot AMI the EBS snapshot is not deleted and can be used separately to create EBS volumes. It can even be registered again as a new AMI. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/deregister-ami.html – Eric Hammond Jan 09 '21 at 23:06
25

The major difference is between the type of service referred to. A snapshot is of an EBS volume where you are able to save state and reboot with the same data at a certain point in time.

An AMI is similar, but its for the EC2 instances themselves. You cannot take a snapshot of a non ebs backed instance, but you can create a AMI (system image) of one.

Generally I use EBS snapshots as backup solutions for a database volume and I use an AMI to save instance configuration

BrianJakovich
  • 1,514
  • 1
  • 12
  • 23
  • 2
    What if my volume contains my databases as well as my instance configuration? What does AMI save that an EBS snapshot doesn't (and vice versa)? Thanks – Melbourne2991 Jul 13 '13 at 02:13
  • 1
    an AMI is immediately launchable to a new instance. an EBS snapshot can be copied to a new volume (virtual disk). That virtual disk can be used as the basis for a new instance, but it isn't an instance by itself. – Dan Pritts Oct 18 '16 at 20:01
16

An AMI can be created using a snapshot. For example, using a single "snapshot" you can create multiple AMIs, say one PV and one HVM AMI using the same snapshot.

So, snapshot has the system / OS data. AMI is (snapshot + machine/hardware metadata).

Anshu Prateek
  • 2,861
  • 1
  • 16
  • 32
  • 1
    if I have an AMI, that an instance was created from it. Does the AMI include the data on that instance? I mean, if the instance contains tomcat WAR files, the the AMI that that instance was created from, includes as well? – Dejell Jun 23 '15 at 12:53
  • 1
    If you create an AMI out of the instance containing tomcat (or any files), then the new created AMI will contain those files / data. Any instance further created from this AMI will have these files. However, the source AMI from which you created the instance will not have them (assuming you added the files to instance after instance creation). – Anshu Prateek Jun 24 '15 at 03:48
16

I was confused by that as well. Here's simplest way of understanding it:

  • EBS Snapshot very often represents a backup of specific EBS volume, it might be any volume (Root volume, data volume, etc.)

  • AMI (Amazon Machine Image) is a backup of Entire EC2 instance. For example, with proper configuration it's possible to create AMI which includes multiple EBS volumes.

Now, it might sound confusing, but they are both stored as a "EBS Snapshots".

Just think of that way:

  • EBS Snapshot is a just a data backup.
  • AMI is a representation of system state at specific time. You can also boot from it.
skryvets
  • 2,102
  • 24
  • 28
  • So if i created a snapshot of the root volume, can that snapshot be used to launch an instance? – gaurav parashar Dec 18 '19 at 01:55
  • 2
    Short answer: No. It can't be done directly using only the volume as the only available "booting option" for EC2 is AMI. However, you can create AMI from the volume and launch an instance from recently created AMI (like an indirect option). – skryvets Dec 20 '19 at 16:31
9

EBS Volume is the underlying disk behind EC2. Snapshot is a point in time backup of specific volume while AMI is is backup of the entire EC2 instance that might have multiple attached volumes, exactly like virtual machines.

With Packer, you can build automated machine images including AMIs for EC2, VMDK/VMX files for VMware, OVF exports for VirtualBox, etc.

EC2  <-- EBS Volume (Boot) + EBS Volume 
                        ^
                        |
                     Snapshot (only of specific volume)       
                        ^
                        |
                       AMI (Combined snapshots of all volumes, snapshot must have boot volume) 
                        ^
                        | 
                  Launch a new Instance (same installed softwares and configs, different specs) 

Snapshots can be used to backup drives/volumes. It is incremental backup operation which means every time you take a snapshot of a volume, it will add only the new changes added/introduced to the volume since your last backup (not entire backup), that saves backup time, space and ultimately the cost.

Snapshots can be used in:

  • Backup drives regularly

  • Change the type of volume, for example you have traffic or reads and writes and need to increase IO operations so you change from gp2 to io1 with higher IOPs

Custom AMIs can be used in:

  • For disaster recovery in case current running EC2 instance corrupted and couldn't run for no reason.

  • Standard company's AMIs that have all installed prerequisites softwares that simplifies the process of deployment (e.g. configured to connect to `Splunk, has some monitoring and observability softwares installed, has docker installed, or it's configured to connect Puppet or Chef in startup)

  • AMIs could be used to deploy your applications in different regions easily.

  • Upgrade your server to higher or different specs with all installed softwares and their configs

  • AMIs can be publicly shared across AWS accounts.

Muhammad Soliman
  • 14,761
  • 4
  • 84
  • 60
5

Here are few more differences between AMI and EBS Snapshots:

1) An AMI is launchable and contains links to the root device and may contain links to snapshots of the other data volumes.

2) The data image contained in an AMI does not represent a well-defined point-in-time, unless the instance is rebooted, something that is typically not acceptable for production environment. Snapshots can be taken in a consistent manner since their exact point-in-time can be controlled, so before the snapshot starts it can be made sure that everything is "ready for backup".

3) An AMI can be created from existing snapshots of the root device for Linux but not for Windows.

OK1
  • 161
  • 2
  • 4
2

As per the definition provided by AWS,

An AMI is a template from which you can start an EC2 instance. An EBS Snapshot is a block level copy of an EBS volume. The EBS volume might be a boot volume (i.e. containing an operating system), or a data-only volume (containing database files for example). You use RegisterImage to create an AMI (from a snapshot).

These are two different concepts, applied at different levels (EBS volumes vs EC2 templates) However, there are some dependencies between the two concepts.

For EBS backed EC2 instances (i.e. EC2 instances that boot from an EBS volume), the AMI is implemented as an EBS Snapshot of a boot volume + a couple of meta data (the architecture of the machine - 32 vs 64 bits -, the type of virtualization - HVM vs PV - etc ...)

So, for EBS backed EC2 instances, an AMI is an EBS snapshot + an XML file. You can even create your own AMI based on any snapshot of a boot volume you own.

1

Snapshots are less expensive to use as a backup strategy, because when you have multiple snapshots, you only pay for one full backup and ther rest are, in essence, just diffs, and usually much smaller.

  • 8
    This is not true for EBS boot AMIs as they *are* exactly EBS snapshots plus a little metadata. The expense would be identical. – Eric Hammond Jul 12 '13 at 18:46
1

You can think of an AMI as a generic template for a machine with OS and installed components being preserved.

A Snapshot can include everything an AMI does, but also saves the disk data of an EBS volume.

Which one you decide to use will generally be dictated by whether your instances are EBS backed and if you want to exactly recreate a machine with all data intact or just want a generic machine template.

CIGuy
  • 4,926
  • 26
  • 37
  • So the AMI doesn't save the EBS volume? – Melbourne2991 Jul 13 '13 at 01:56
  • 1
    An AMI can be set to include one or more EBS volumes, but those volumes will be blank on boot, they will not contain the data which the original source machine contained. – CIGuy Jul 14 '13 at 20:06
  • So the AMI is really just meta data (not sure if that's the right term)? Like what OS you're using, the size of the instance etc? It should technically be only a few kb in size I take it? – Melbourne2991 Jul 15 '13 at 01:15
  • 1
    An AMI also stores any programs you have installed on the machine, os level configuration options etc... so it isn't really just meta-data, but yes they are usually much smaller than a snapshot. – CIGuy Jul 15 '13 at 02:12
  • 2
    This answer is wrong. An AMI includes one or more snapshots. That is, it references one or more snapshots (there's no data copying), and also holds some additional metadata. This is why you cannot delete a snapshot if it is current being used by an AMI. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html See also Eric Hammond's contributions in this thread. – Max Barraclough Dec 31 '19 at 15:35
0

From the definition provided by AWS it clarifies the difference - An Amazon Machine Image (AMI) is a template that contains a software configuration (for example, an operating system, an application server, and applications). From an AMI, you launch an instance, which is a copy of the AMI running as a virtual server in the cloud. Whereas for Snapshots You can back up the data on your EBS volumes to Amazon S3 by taking point-in-time snapshots. Snapshots are incremental backups, which means that only the blocks on the device that have changed after your most recent snapshot are saved. When you delete a snapshot, only the data exclusive to that snapshot is removed.