Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Overview of the Issue
Using optional in variables of type object isn't working in Packer, but working in Terraform.
Reproduction Steps
# foo.pkr.hcl
variable "context" {
type = object({
bar_pro = optional(string, "bar")
})
}
$> packer validate foo.pkr.hcl
Error: Invalid type specification
on foo.pkr.hcl line 3, in variable "context":
3: bar_pro = optional(string, "bar")
Optional attribute modifier is only for type constraints, not for exact types.
# main.tf has exactly same content as foo.pkr.hcl
# tf init etc ommited
$> terraform validate
Success! The configuration is valid.
Packer version
Packer v1.8.5
Terraform v1.3.6
Operating system and Environment details
Linux fedora 6.0.15-300.fc37.x86_64
Community Note
Overview of the Issue
Using optional in variables of type object isn't working in Packer, but working in Terraform.
Reproduction Steps
Packer version
Packer v1.8.5
Terraform v1.3.6
Operating system and Environment details
Linux fedora 6.0.15-300.fc37.x86_64