Hello,
I’m not sure what I’m doing wrong here. At the top of template.pkr.hcl
(main config file that I’m running with packer) I have the following:
locals {
internal_01_gw = cidrhost(var.internal_01, 1)
}
In variables.pkr.hcl
(inside the same directory) I have this:
variable "internal_01" {
default = "10.10.111.0/24"
type = string
}
I’m running packer as follows:
packer build -var-file="secrets.pkrvars.hcl" -var-file="values.pkrvars.hcl" template.pkr.hcl
But I keep getting this error:
Error: Unsupported attribute
on template.pkr.hcl line 2:
(source code not available)
This object does not have an attribute named "internal_01".
In the documentation related to variables, I see that packer is supposed to read all files ending in pkr.hcl: Input and Local Variables guide | Packer | HashiCorp Developer
That doesn’t seem to be the problem anyway, because, even if I define internal_01
in the same file, I still get the same error, so it literally cannot find the variable and I don’t understand why. Any ideas how I can solve this?