Is there a documented set of steps for cleaning an AWS instance before taking a snapshot to create an AMI?

35 views Asked by At

When creating a custom AMI, the process that one typically follows is as follows.

  1. Boot an EC2 instance.
  2. Install whatever is needed.
  3. Snapshot the hard drive.

The problem is that the newly booted EC2 instance has various bits that do not exist in a "clean" AMI image, such as the following

  • The original ssh key we used to login and install stuff.
  • Various files in /var/lib/cloud
  • Various files in /var/log/
  • ...

I came across this gist that is supposed to clean an instance, but it is incomplete because it does not clean up /var/lib/cloudinit and possibly other bits I'm not aware of.

Is there documentation on the exact directories or files that need to be removed to create a "clean" image similar to an official AWS AMI?

0

There are 0 answers