You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my company, we managed to achieve 100% IaC cloud infrastructure definition (Terraform, thanks to you guys!), so every cloud project has its cloud infrastructure defined at terraform layer.
However, custom VM images do still require a separate building step, which happens manually (or via pipelines) using packer.
Therefore, our ambition, is to have the packer step handled in the same place where infrastructure definition takes place. In other words we'd like to have the packer-init + packer-build commands executed while applying a terraform file, so that the resulting image can be referenced in terraform VMs. In this way, if any of the packer definition steps change, terraform will trigger the image build step, assign a new version to the image, and all the terraform VMs referencing that image would update accordingly.
Attempted Solutions
At the moment, we use some local-exec tricks to make it happen. All our packer scripts require a "image-name" to be passed as variable. That image name is later referenced in Terraform VMs and, using depends_on, we force the packer step to happen before the usage of such images. The packer step is basically handled via null_resource, leveraging triggers to control whether or not the packer image should be re-built.
Proposal
The idea is to have a "Packer" provider at terraform level that handles Image resources. A packer-image resource would take as input the packer build json/HCL and return, as output, the image-id of the built artifact.
Current Terraform Version
Use-cases
In my company, we managed to achieve 100% IaC cloud infrastructure definition (Terraform, thanks to you guys!), so every cloud project has its cloud infrastructure defined at terraform layer.
However, custom VM images do still require a separate building step, which happens manually (or via pipelines) using packer.
Therefore, our ambition, is to have the packer step handled in the same place where infrastructure definition takes place. In other words we'd like to have the packer-init + packer-build commands executed while applying a terraform file, so that the resulting image can be referenced in terraform VMs. In this way, if any of the packer definition steps change, terraform will trigger the image build step, assign a new version to the image, and all the terraform VMs referencing that image would update accordingly.
Attempted Solutions
At the moment, we use some local-exec tricks to make it happen. All our packer scripts require a "image-name" to be passed as variable. That image name is later referenced in Terraform VMs and, using
depends_on
, we force the packer step to happen before the usage of such images. The packer step is basically handled vianull_resource
, leveraging triggers to control whether or not the packer image should be re-built.Proposal
The idea is to have a "Packer" provider at terraform level that handles Image resources. A packer-image resource would take as input the packer build json/HCL and return, as output, the image-id of the built artifact.
References
The text was updated successfully, but these errors were encountered: