Terraform: "local-exec provisioner command must be a non-empty string" on local-exec destroy provisioner when self. references are used. 13-beta3

Created on 7 Aug 2020  ·  2Comments  ·  Source: hashicorp/terraform

Terraform Version

➜ tf -v
Terraform v0.13.0-beta3
+ provider registry.terraform.io/hashicorp/null v2.1.2

Terraform Configuration Files

resource null_resource test {
  triggers = {
    test = "FOO"
  }

  provisioner local-exec {
    command = "echo Create${self.triggers.test}"
  }

  provisioner local-exec {
    command = "echo Destroy${self.triggers.test}"
    when = destroy
  }
}

Debug Output

https://gist.github.com/choovick/e843ba297ebd6668fdcac6a52dc93156

Expected Behavior

This all work in latest Terraform 12 but not in 13-beta3

Actual Behavior

➜ tf apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # null_resource.test will be created
  + resource "null_resource" "test" {
      + id       = (known after apply)
      + triggers = {
          + "test" = "FOO"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

null_resource.test: Creating...
null_resource.test: Provisioning with 'local-exec'...
null_resource.test (local-exec): Executing: ["cmd" "/C" "echo CreateFOO"]
null_resource.test (local-exec): CreateFOO
null_resource.test: Creation complete after 1s [id=1641541723211737950]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.


➜ tf destroy
null_resource.test: Refreshing state... [id=1641541723211737950]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # null_resource.test will be destroyed
  - resource "null_resource" "test" {
      - id       = "1641541723211737950" -> null
      - triggers = {
          - "test" = "FOO"
        } -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

null_resource.test: Destroying... [id=1641541723211737950]
null_resource.test: Provisioning with 'local-exec'...


Error: local-exec provisioner command must be a non-empty string

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. terraform destroy

Additional Context

Remove reference from destroy provisioner command and its gonna work, but that not desired use case.

References

Similar to #24174 but without count involvement in 13

  • #24174
bug new

Most helpful comment

Hi @choovick

This appears to be a duplicate of #25617, and should work correctly in the current release.

If you still encounter an error, feel free to reply here and we can re-asses the issue.

All 2 comments

Hi @choovick

This appears to be a duplicate of #25617, and should work correctly in the current release.

If you still encounter an error, feel free to reply here and we can re-asses the issue.

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.

Was this page helpful?
0 / 5 - 0 ratings