Build Your Own Custom AMI With Packer
Yup, that's me again... dealing with some new pain in the neck and then writing about it.
And this time let me tell you a few things about mutable infrastructure or even more specific, how to build your own using Packer and AWS.
So, for the past 2 years or so I have been working in an amazing company where I lead the Automation Infra team. A team of awesome and super talented all around infra developers that basically maintain the entire QA Guild's infrastructure including automation, pipelines, custom AWS resources and much more.
In the scope of our work, dynamic EC2 instances are heavily in use for various deployment and automation needs. The need for dynamic mutable infrastructure is a very common need and in the era of cloud providers and various open source and commercial solutions we are able to address that need effectively.
So, What is Packer?Packer is an open-source tool for creating Machine Images from source configuration developed by HashiCorp. (And if you are in the operations game, that name would ring a few bells for you for sure).
In that script we can put what ever we want in order to provision our ubuntu server. For example we can enable Universe repository, update apt, install ec2 connect for AWS, download and install software etc...
Ones we have our script ready lats pass in the location of the script and the provisioner type into our configuration file as mentioned earlier: