Writing Packer templates with HCL format
Since the release of version 1.5.0 of Packer, it's possible to write Packer templates using HCL format, which we learned in detail in Chapter 2, Provisioning Cloud Infrastructure with Terraform.
Note
The HCL integration in Packer is currently in Beta, and will be preferred by HashiCorp from version 1.7.0.
The HCL format of the template is very similar to the JSON format and it's composed of variable
, source
, build
, and provisioner
blocks. The following code shows the structure of the HCL Packer template.
For writing an HCL template, create a file, .pkr.hcl
, that contains all the following code:
packer { required_plugins { azure = { version = ">= 1.0.0" &...