Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packer optional behavior is different than Terraform #12182

Open
zeidoo opened this issue Jan 3, 2023 · 4 comments
Open

Packer optional behavior is different than Terraform #12182

zeidoo opened this issue Jan 3, 2023 · 4 comments
Labels
bug stage/waiting-on-upstream This issue is waiting on an upstream change sync to jira For issues that need to be imported to Packer internal JIRA backlog
Milestone

Comments

@zeidoo
Copy link

zeidoo commented Jan 3, 2023

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

@zeidoo zeidoo added the bug label Jan 3, 2023
@github-actions github-actions bot removed the bug label Jan 3, 2023
@zeidoo zeidoo changed the title Packer optional behavior is different that Terraform Packer optional behavior is different than Terraform Jan 3, 2023
@sestegra
Copy link

sestegra commented Feb 11, 2023

This feature needs newer version of github.com/hashicorp/hcl/v2 and github.com/zclconf/go-cty.

But, the update is blocked by the following issues:

The root cause is the removal of the support of enconding/gob in cty module (zclconf/go-cty@97bafac).

@nywilken nywilken added bug stage/waiting-on-upstream This issue is waiting on an upstream change sync to jira For issues that need to be imported to Packer internal JIRA backlog labels Feb 21, 2023
@github-actions
Copy link

This issue has been synced to JIRA for planning.

JIRA ID: HPR-982

@nywilken nywilken added this to the 1.9.0 milestone Feb 21, 2023
@nywilken
Copy link
Member

@sestegra thanks for the added context. I'm actually starting to look into hashicorp/packer-plugin-sdk#135. I'll update the thread once I have some insight on how to best proceed.

@sestegra
Copy link

@nywilken
This issue is on a closed Milestone.
Since plugin-packer-sdk bumps to 0.5.2 with go-cty update, I guess this issue can be fixed in the next milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stage/waiting-on-upstream This issue is waiting on an upstream change sync to jira For issues that need to be imported to Packer internal JIRA backlog
Projects
None yet
Development

No branches or pull requests

3 participants