When creating a custom AMI, the process that one typically follows is as follows.
- Boot an EC2 instance.
- Install whatever is needed.
- 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?