Consuming HCP Packer from Terraform
Terraform is HashiCorp’s tool for infrastructure as code. Terraform is largely out of scope for this book, but we will at least cover how to use HCP Packer to deploy your images registered with HCP. The good news is that Packer’s data source type actually started out as a Terraform feature. The key feature in Terraform is simply being able to look up the IDs of the AMIs built with Packer:
data "hcp_packer_image_version" "gpu-test" { bucket_name = "al-gpu" channel = "test" }
If this looks familiar, it’s because the Packer data source and the Terraform data source use the same syntax and the same API behind the scenes. Now, as you update your release channels in HCP Packer, those changes will automatically be picked up by subsequent Terraform runs:
data "hcp_packer_image" "amiid" { bucket_name ...