2

I am using packer to generate AMIs that are preconfigured with some programs - both installed from apt and compiled from source. I would like to be able to tag the generated AMI with the versions of the installed programs but I can't figure out how I would do that.

On the provisioned machine I would run:

program --version

and get something like

v1.3

The problem is I'm not able to run this until after the machine is provisioned and install so I am unable to add that information to the template file prior to running packer build.

Does anyone have any suggestions for how I can accomplish this?

guribe94
  • 1,551
  • 3
  • 15
  • 29

1 Answers1

2

for the software versions you know up ahead, you can use the tags property "amazon-ebs" builder. if it's going to be dynamic/ install latest available version, then you can have a script that prints out the software version to a file and use the File provisioner with direction set to "download", so the file is available on the host.

Then you can read the file and run "aws ec2 create-tags" command to add additional tags to the ami.

mockora
  • 106
  • 2