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

Specify variables when parsing jobs into JSON #451

Open
rodrigol-chan opened this issue Apr 17, 2024 · 0 comments
Open

Specify variables when parsing jobs into JSON #451

rodrigol-chan opened this issue Apr 17, 2024 · 0 comments

Comments

@rodrigol-chan
Copy link
Contributor

Terraform Version

Terraform v1.7.5
on linux_amd64
+ provider registry.terraform.io/hashicorp/nomad v2.1.0

Your version of Terraform is out of date! The latest version
is 1.8.1. You can update by downloading from https://www.terraform.io/downloads.html

Nomad Version

1.6.8

Provider Configuration

Which values are you setting in the provider configuration?

provider "nomad" {
  address = "http://localhost:4646"
}

Affected Resource(s)

  • data.nomad_job_parser

Terraform Configuration Files

data "nomad_job_parser" "job" {
  hcl = <<-EOJ
    variable "greeting" {
      type = string
    }
    job "hello" {
      type = "batch"
      group "hello" {
        task "hello" {
          driver = "raw_exec"
          config {
            command = "/bin/echo"
            args = [var.greeting]
          }
        }
      }
    }
  EOJ

  # Not available:
  # vars = ...
}

Expected Behavior

Variables should be able to be set when parsing the job.

Actual Behavior

Because variables are not supported when parsing a job, the job fails to parse:

╷
│ Error: error parsing job: api.UnexpectedResponseError{expected:[]int{200}, statusCode:400, statusText:"Bad Request", body:"Failed to parse job: <nil>: Unset variable \"greeting\"; A used variable must be set or have a default value; see https://www.nomadproject.io/docs/job-specification/hcl2/variables for details.", err:error(nil), additional:error(nil)}
│
│   with data.nomad_job_parser.job,
│   on main.tf line 1, in data "nomad_job_parser" "job":
│    1: data "nomad_job_parser" "job" {
│
╵
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant