thebeancounter
thebeancounter

Reputation: 4839

AWS EC2 get the AMI size

I am Using ec2 and creating a custom AMI using a snapshot for my machine. I Can't find how to get it's actual size on disk to calculate the cost it will charge me to store it.

How can I get the actual compressed size or estimated cost for storing an AMI (snapshot of a machine)

Upvotes: 3

Views: 5496

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269274

AMI sizes are not easy to calculate. This is because they are based on Amazon EBS snapshots, and EBS snapshots are incremental in nature.

For example:

  • Let's say you launch an instance from an Amazon Linux AMI
  • You then login and create a file on the disk
  • You then create a new AMI

Any blocks that have been added or changed (eg for the new file on the disk) will be included in your AMI (or, more accurately, in the snapshot that stores the AMI data). However, all the blocks that were not modified from the original AMI are not stored in your AMI. Instead, the AMI will contain a reference to the blocks in the original AMI. This is due to the incremental nature of snapshots.

So, the reality is that most of an AMI (most of a snapshot) actually contains pointers to existing data and it therefore is not charged to you. You will only pay for storage that does not already exist.

That's why you can't really get the storage size of an AMI.

The only way to know the storage size for sure would be to create a totally new AMI that is not based on an existing AMI, since you would then be charged for the total size. (I wouldn't recommend doing so.)

Upvotes: 6

Related Questions