Cost of storing AMI

Amazon Web-ServicesAmazon Ec2

Amazon Web-Services Problem Overview


I understand Amazon will charge per GB provisioned EBS storage. If I create AMI of my instance, does this mean my EBS volume will be duplicated, and hence incur additional cost?

Is there other cost charge in creating and storing an AMI (Amazon Machine Image)?

Amazon Web-Services Solutions


Solution 1 - Amazon Web-Services

You are only charged for the storage of the bits that make up your AMI, there are no charges for creating an AMI.

  • EBS-backed AMIs are made up of snapshots of the EBS volumes that form the AMI. You will pay storage fees for those snapshots according to the rates listed here. Your EBS volumes are not "duplicated" until the instance is launched, at which point a volume is created from the stored snapshots and you'll pay regular EBS volume fees and EBS snapshot billing.

  • S3-backed AMIs have their information stored in S3 and you will pay storage fees for the data being stored in S3 according to the S3 pricing, whether the instance is running or not.

Solution 2 - Amazon Web-Services

In this case, you will pay for the size of the storage used, instead of the storage provisioned. Snapshots will not store any empty blocks.

Solution 3 - Amazon Web-Services

In short, yes, you will incur additional charges, but at a less rate, namely, EBS snapshot storage rate. Provisioned EBS is the 'live' HD that will be charged at $0.10 per GB per month if using standard SSD (gp2, USA east pricing for 2022 used throughout). And if you provisioned 50 GB, you will be fully charged for that 50 GB, even if you are only using 5% of it. The charges will incur even if you forget to attach to an EC2 instance. $5 per month in this case.

When you create an AMI, AWS will create a snapshot in the background. This snapshot is viewable under EBS Snapshots and will not be deletable as long as that AMI is in existence. You will get an error if you try to delete this snapshot. Snapshots cost less than 'provisioned' EBS at $0.05 per GB per month, and since snapshots ignore empty blocks, it will be shrunk to used size, so if you are only using 5% of 50GB, the snapshot should only be around 2.5 GB. $0.13 per month in this case. No other charges.

If you are creating a lot of these, it can get expensive very quickly, so some people save these AMIs into S3, which is cheaper than EBS snapshots. This is somewhat advanced and as far as I know, it can only be done via AWS CLI, and not in the console. You use a command called aws ec2 create-store-image-task and you have to specify the destination bucket name, and make sure permissions for S3, EBS and EC2 will all allow it. More detail at the official AWS documentation. This would reduce the cost to about $0.023 per GB per month. There are other changes relating to this method, i.e. EBS Direct API, but it is not much and you can look it up in the documentations.

Recently in November 2021, AWS released archived function for EBS snapshots, which allows you to archive your snapshots for a minimum of 90 days for $0.0125. You do have to pay $0.03 per GB for restoring the data. However, this is designed for EBS backups (e.g. daily backups using snapshots) and you cannot archive an EBS snapshot that is associated with an AMI. You will get an error: Failed to archive snapshot... snap-xyz is in use by ami-123.

Below is an excerpt of an actual AWS bill that will explain it in a visual sense.

Here is an excerpt of an actual AWS bill that shows the billing.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongerrytanView Question on Stackoverflow
Solution 1 - Amazon Web-ServicesGreg KempeView Answer on Stackoverflow
Solution 2 - Amazon Web-ServicesdatasageView Answer on Stackoverflow
Solution 3 - Amazon Web-ServicesJasonView Answer on Stackoverflow