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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hcl2_upgrade command for Amazon build template data misses some variables #11920

Closed
hegyre opened this issue Aug 4, 2022 · 2 comments · Fixed by #12068
Closed

hcl2_upgrade command for Amazon build template data misses some variables #11920

hegyre opened this issue Aug 4, 2022 · 2 comments · Fixed by #12068
Assignees
Labels
command/hcl2_upgrade hcl2 sync to jira For issues that need to be imported to Packer internal JIRA backlog

Comments

@hegyre
Copy link

hegyre commented Aug 4, 2022

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

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

Hello,
When converting a JSON template to HCL, there's a number of "<no value>" strings for some variables.
The resulting HCL file gives:

source "amazon-ebs" "autogenerated_1" {
  [...]
  run_tags = {
    SourceAMI             = "{{ .SourceAMI }}"
    SourceAMICreationDate = "<no value>"
    SourceAMIName         = "{{ .SourceAMIName }}"
    SourceAMIOwner        = "<no value>"
    SourceAMIOwnerName    = "<no value>"
    SourceAMITags         = "<no value>"
  }
  [...]
  tags = {
    SourceAMI             = "{{ .SourceAMI }}"
    SourceAMICreationDate = "<no value>"
    SourceAMIName         = "{{ .SourceAMIName }}"
    SourceAMIOwner        = "<no value>"
    SourceAMIOwnerName    = "<no value>"
    SourceAMITags         = "<no value>"
  }

Instead of "<no value>", I expect to have the same kind of values as for SourceAMI and SourceAMIName.
Those variables are legit, as per https://www.packer.io/plugins/builders/amazon/ebs#build-template-data and the given Tag Example.

Reference issue that adds those variables: #9750 (fixed by #9751)

Reproduction Steps

Run packer hcl2_upgrade ami.json

See below for the json content.

Packer version

Packer v1.8.3

Simplified Packer Template

Create a JSON template like this:

  "builders": [
    {
      "type": "amazon-ebs",
      [...]
      "tags": {
        "SourceAMIName" : "{{ .SourceAMIName }}",
        "SourceAMI" : "{{ .SourceAMI }}",
        "SourceAMICreationDate" : "{{ .SourceAMICreationDate }}",
        "SourceAMIOwner" : "{{ .SourceAMIOwner }}",
        "SourceAMIOwnerName" : "{{ .SourceAMIOwnerName }}",
        "SourceAMITags": "{{ .SourceAMITags.TagName }}",
      },
      "run_tags": {
        "SourceAMIName" : "{{.SourceAMIName}}",
        "SourceAMI" : "{{.SourceAMI}}",
        "SourceAMICreationDate" : "{{.SourceAMICreationDate}}",
        "SourceAMIOwner" : "{{.SourceAMIOwner}}",
        "SourceAMIOwnerName" : "{{.SourceAMIOwnerName}}",
        "SourceAMITags": "{{ .SourceAMITags.TagName }}",
      }
    }
  ]

Operating system and Environment details

Windows 10 21H2, using PowerShell 5.1 to run Packer

Log Fragments and crash.log files

2022/08/04 19:29:06 [INFO] Packer version: 1.8.3 [go1.17.11 windows amd64]
2022/08/04 19:29:06 [TRACE] discovering plugins in C:\HashiCorp\Packer\bin
2022/08/04 19:29:06 [TRACE] discovering plugins in C:\Users\phegy01\AppData\Roaming\packer.d\plugins
2022/08/04 19:29:06 [TRACE] discovering plugins in .
2022/08/04 19:29:06 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/08/04 19:29:06 [INFO] PACKER_CONFIG env var set; attempting to open config file: C:\Users\phegy01\AppData\Roaming\packer.config
2022/08/04 19:29:06 [WARN] Config file doesn't exist: C:\Users\phegy01\AppData\Roaming\packer.config
2022/08/04 19:29:06 [INFO] Setting cache directory: C:\git\VAG\vagrant-salt-dcsie\packer-dcsie\packer_cache
e: cannot determine if process is in background: Process background check error: not implemented yet
2022/08/04 19:29:06 ui: Successfully created ami-php81.json.pkr.hcl. Exit 0
2022/08/04 19:29:06 [INFO] (telemetry) Finalizing.
2022/08/04 19:29:06 waiting for all plugin processes to complete...


@hegyre hegyre added the bug label Aug 4, 2022
@github-actions github-actions bot removed the bug label Aug 4, 2022
@nywilken nywilken added the sync to jira For issues that need to be imported to Packer internal JIRA backlog label Sep 30, 2022
@github-actions
Copy link

This issue has been synced to JIRA for planning.

JIRA ID: HPR-759

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
command/hcl2_upgrade hcl2 sync to jira For issues that need to be imported to Packer internal JIRA backlog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants