Last active
October 13, 2024 17:31
-
-
Save albertogeniola/0aa5b27e6bc51a3681bbc90be1275aea to your computer and use it in GitHub Desktop.
Run packer build from Terraform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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