databricks / cli

Databricks CLI
Other
132 stars 50 forks source link

Complex variable with reference to another variable fails in deploy despite passing validation #1541

Closed marcinmilewski1 closed 2 months ago

marcinmilewski1 commented 3 months ago

Describe the issue

Despite bundle validate command passes, the deploy fails due to the "Reference to undeclared input variable" error:

Error: terraform apply: exit status 1

Error: Reference to undeclared input variable

  on bundle.tf.json line 86, in resource.databricks_job.cicd_template_job.task[2].library[0].pypi:
  86:                   "package": "cicd_template==${var.package_version}"

An input variable with the name "package_version" has not been declared. This
variable can be declared with a variable "package_version" {} block.

Configuration

variables:
  package_version:
    default: "1"
  cluster_libraries:
    type: complex
    default:
      - pypi:
          package: "cicd_template==${var.package_version}"

Expected Behavior

Complex variable with reference to declared variable should pass

Actual Behavior

Complex variable with reference to declared variable fails in deploy despite passing validation

OS and CLI version

Databricks CLI v0.222.0

pietern commented 3 months ago

Thanks for reporting.

It's odd that this is not working for you as it looks very similar to one of the test cases: https://github.com/databricks/cli/blob/a0df54ac4131a4eb6c91e2a5da153c22cdd256e2/bundle/tests/variables/complex/databricks.yml#L16-L28

We'll investigate and figure it out.

andrewnester commented 2 months ago

Thanks for the reporting! The fix has been merged and will be released in the upcoming release this week

marcinmilewski1 commented 2 months ago

Thank you Andrew!