Create an AMI with reduced size root volume to save cost

AWS has democratized IT infrastructure so today any individuals can start a nimble company with near zero upfront capital investment. While I love AWS so much I still routinely find things that could be, and should have been, improved.  One good example is the EC2 AMI root volume sizes.  For example, an 8GB root volume gets created when launched from the Amazon Linux AMI, or 30GB from the Windows Server AMI.  The size varies depending on the backing AMI images.

Initially it may not sound a lot given that it only costs $3 for the 30GB EBS gp2 volume.  But if you only need 15GB why waste the $1.5 per month for the extra space you don’t need?  Or, a lot of times we simply wanted to quickly get things started so we played safe by provisioning a bit more than what we really needed.  But once things started working we didn’t want to reconfigure the whole stack from scratch, hence we found ourselves stuck with paying for it month after month.  What’s worse, these wastes accumulate fast in scale.  So it’s especially important to give some thoughts before deploying resources in cloud because they are going to multiply quickly.

One thing we have done to minimize such waste is to create an AMI the team routinely use by reducing the root volume size to the minimal, e.g. from 8GB to 2GB for the Amazon Linux AMI. See my previous blogs How to get around the 8GB limit on root volumes in AWS and How to shrink EBS root volumes in AWS – with just one click for how to do it.  Once we’ve got the reduced root volume EC2 instance working we can then create an AMI from the instance and share it with the team.  

In our case, we’ve already been customizing AMIs for team use, so it’s just an extra step to optimize our AMIs.  When launching a new instance from the AMIs simply specify the desired new root volume size.  When the instance starts both root partition and filesystems are resized automatically.  Not only does it save the EBS usage costs, it also saves the backup snapshot costs.

Other Related Blogs

FittedCloud Cloud Cost Optimization Solutions
FittedCloud offers machine learning based cloud cost optimization solutions that help customers reduce AWS spend significantly. Our current solutions include machine learning driven actionable advisories with click through actions for EC2, EBS, RDS, DynamoDB, ElastiCache, ElasticSearch, AutoScale, Lambda, etc. and full/lights out automation for EC2, EBS, DynamoDB and RDS. Our solution typically can save customers up to 50% of their cost on AWS. For more details, please visit https://www.fittedcloud.com/.