a packer pattern

Dec 27, 2024
  • create the ec2 instance from terraform
  • use the ec2 user data to write a "context.yaml" file and run bootstrap.sh via runcmd (the script is already part of the packer image)
  • the bootstrap.sh script will use context.yaml and templates already part of the packer images to render definitive files (e.g. systemd units, with Environment= based on a sensitive value in terraform)
  • bootstrap.sh will finally run a “daemon-reload”, start the needed services, and exit

Notes:

  1. for templates, I’m using https://github.com/hairyhenderson/gomplate
  2. my former colleague @gi0baro showed me this pattern first

--

--

No responses yet