Skip to content

Instantly share code, notes, and snippets.

@albertogeniola
Last active October 13, 2024 17:31
Show Gist options
  • Select an option

  • Save albertogeniola/0aa5b27e6bc51a3681bbc90be1275aea to your computer and use it in GitHub Desktop.

Select an option

Save albertogeniola/0aa5b27e6bc51a3681bbc90be1275aea to your computer and use it in GitHub Desktop.
Run packer build from Terraform
# This is the resource that will trigger the packer image creation
resource "terraform_data" "packer_image" {
triggers_replace = [local.packer_contents_hash, local.image_source_build_params, local.image_target_build_params]
provisioner "local-exec" {
when = create
working_dir = "${path.module}/packer/"
command = "packer build ${local.image_source_build_params} ${local.image_target_build_params} -var region=${var.builder_region} -var project_id=${var.builder_project_id} -var zone=${var.builder_zone} -var network_project_id=${local.builder_network_project_id} -var network_name=${var.builder_network_name} -var subnet_name=${var.builder_subnet_name} image.pkr.hcl"
}
depends_on = [ google_project_service.services ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment