➜ tf -v
Terraform v0.13.0-beta3
+ provider registry.terraform.io/hashicorp/null v2.1.2
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
}
}
https://gist.github.com/choovick/e843ba297ebd6668fdcac6a52dc93156
This all work in latest Terraform 12 but not in 13-beta3
➜ 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
terraform initterraform applyterraform destroyRemove reference from destroy provisioner command and its gonna work, but that not desired use case.
Similar to #24174 but without count involvement in 13
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.
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.