Packer Version 1.6.1
I'm trying to include variable blocks with json format
foo.pkr.json
{
"variable": {
"project_id": {
"type": "string",
"description": "Project ID in GCP",
"default": ""
}
}
}
foo.pkrvars.json
{
"project_id": "xxx"
}
when I run packer build -var-file="foo.pkrvars.json" .
getting output as
==> Builds finished but no artifacts were created.
Hey there! So, I guess you should be using an HCL2 template instead of JSON in order to use the foo.pkrvars.json
, the command line your using and to define the project_id
variable as you did.
I suggest you create a variables.pkr.hcl
file with:
variable "project_id" {
type = string
description = "Project ID in GCP"
default = ""
}
And upgrade your JSON template to HCL2 using the hcl2_upgrade command.
To keep working with JSON, you can the template with the correct form of the variables block like:
{
"variables": {
"project_id": ""
}
}
and build the VM with the command: packer build -var 'project_id=xxx' foo.json
I suggest checking out the docs about user variables in JSON templates HERE and also the one about user variables in HCL2 HERE.
I'll close the issue but feel free to follow up with questions if you need some help.
Hey thanks updating to hcl2 solved my issue
https://ggktech.com/
Thanks,
Tejaswini Tharigopula
From: Sylvia Moss notifications@github.com
Sent: Friday, September 11, 2020 2:39 PM
To: hashicorp/packer packer@noreply.github.com
Cc: T, Tejaswini tejaswini.t@acsicorp.com; Author author@noreply.github.com
Subject: Re: [hashicorp/packer] Builds finished but no artifacts were created when variable blocks are Incuded (#9929)
Hey there! So, I guess you should be using an HCL2 template instead of JSON in order to use the foo.pkrvars.json, the command line your using and to define the project_id variable as you did.
I suggest you create a variables.pkr.hcl file with:
variable "project_id" {
type = string
description = "Project ID in GCP"
default = ""
}
And upgrade your JSON template to HCL2 using the hcl2_upgradehttps://www.packer.io/docs/commands/hcl2_upgrade command.
To keep working with JSON, you can the template with the correct form of the variables block like:
{
"variables": {
"project_id": ""
}
}
and build the VM with the command: packer build -var 'project_id=xxx' foo.json
I suggest checking out the docs about user variables in JSON templates HEREhttps://www.packer.io/docs/templates/user-variables and also the one about user variables in HCL2 HEREhttps://www.packer.io/docs/from-1.5/variables.
I'll close the issue but feel free to follow up with questions if you need some help.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/hashicorp/packer/issues/9929#issuecomment-690973119, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALV7XCYYWQDSYDSZBQ3UQ6LSFHSM5ANCNFSM4RGRG7NQ.
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.
Most helpful comment
Hey thanks updating to hcl2 solved my issue
https://ggktech.com/
Thanks,
Tejaswini Tharigopula
From: Sylvia Moss notifications@github.com
Sent: Friday, September 11, 2020 2:39 PM
To: hashicorp/packer packer@noreply.github.com
Cc: T, Tejaswini tejaswini.t@acsicorp.com; Author author@noreply.github.com
Subject: Re: [hashicorp/packer] Builds finished but no artifacts were created when variable blocks are Incuded (#9929)
Hey there! So, I guess you should be using an HCL2 template instead of JSON in order to use the foo.pkrvars.json, the command line your using and to define the project_id variable as you did.
I suggest you create a variables.pkr.hcl file with:
variable "project_id" {
type = string
description = "Project ID in GCP"
default = ""
}
And upgrade your JSON template to HCL2 using the hcl2_upgradehttps://www.packer.io/docs/commands/hcl2_upgrade command.
To keep working with JSON, you can the template with the correct form of the variables block like:
{
"variables": {
"project_id": ""
}
}
and build the VM with the command: packer build -var 'project_id=xxx' foo.json
I suggest checking out the docs about user variables in JSON templates HEREhttps://www.packer.io/docs/templates/user-variables and also the one about user variables in HCL2 HEREhttps://www.packer.io/docs/from-1.5/variables.
I'll close the issue but feel free to follow up with questions if you need some help.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/hashicorp/packer/issues/9929#issuecomment-690973119, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALV7XCYYWQDSYDSZBQ3UQ6LSFHSM5ANCNFSM4RGRG7NQ.