We have several golden AMIs that teams have built AMIs off of (children), some AMIs are built off of those (grand children), and now we'd like to figure out how to track the decendant to its parent golden AMI. There is a /etc/os-release
for the Amazon AMIs which is useful but it makes it harder to find the AMIs in between.
Possible solutions
Tagging of AMIs and tagging of decendent AMIs
"tags": {
"source_ami": "{{ .SourceAMI }}",
"source_ami_name": "{{ .SourceAMIName }}",
"source_ami_date": "{{ .SourceAMICreationDate }}"
}
Manifest json file (example) downloaded to EC2 upon boot
manifest.json
, upload it to a prefix according to its respective AMI e.g. aws s3 cp manifest.json s3://bucket-ami-output/<ami-id>/manifest.json
, and then have the EC2 launch use a /etc/rc.local
script to hit its metadata to get its AMI, download the respective AMI manifest.json
, check for a non-existent /etc/os-<parent-id>.json
e.g. /etc/os-0.json
. If os-0.json
already exists, increment the parent id until one is available. Finally, move the json file to available file on the system.http://169.254.169.254/latest/meta-data/ami-id
to get the current AMI during the packing process and then dump that information into a /etc/os-0.json
file.I'm leaning to the first approach because it seems much simpler.
Amazon EC2 started supporting lineage information for the AMIs. More information can be found in the AWS documentation. This means you no longer need to write custom scripts.