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

on-destroy local-exec: provisioner command must be a non-empty string #25617

Closed
TamasNeumer opened this issue Jul 20, 2020 · 2 comments
Closed
Labels
v0.13 Issues (primarily bugs) reported against v0.13 releases

Comments

@TamasNeumer
Copy link

Issue

  • I'm using the vault provider and before destroying the vault_database_secret_backend_static_role I want to revoke all leases using an API call. (I achieve this using a local-exec provider. Long story short: The command contains reference to self.triggers.xyz which I see in the tfstate, but IMO doesn't resolve properly. I have simplified the use case to the following:
terraform {
  required_version = ">= 0.13"
}

locals {
  message = "Hello there"
}

resource "null_resource" "example1" {
  provisioner "local-exec" {
    command = "echo \"Is it a new bug?\""
  }

  triggers = {
    message = local.message
  }

  provisioner "local-exec" {
    when        = destroy
    interpreter = ["/bin/bash", "-c"]
    command     = "echo ${self.triggers.message}"
  }
}

Expected behavior:

  • "Hello there" printed.

Actual behavior:

  • Error: local-exec provisioner command must be a non-empty string
  • Have I had hardcoded "echo HelloThere", it would have worked. To me it seems the problem is having the variable in the command.

Terraform Version

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

Debug Output

Gist

Steps to Reproduce

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

References

I found the following ticket, which points out, that this shoud be the recommended way to work with variables from on-destroy local-exec resources.

@jbardin
Copy link
Member

jbardin commented Jul 20, 2020

Hi @TamasNeumer

Thanks for reporting this! You are correct that the self reference should still work for the destroy time provisioner.
I verified this is working in master, and will be fixed in the next 0.13 development release.

@ghost
Copy link

ghost commented Aug 20, 2020

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.

@ghost ghost locked and limited conversation to collaborators Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
v0.13 Issues (primarily bugs) reported against v0.13 releases
Projects
None yet
Development

No branches or pull requests

2 participants