From c376905adcedb26b4048529809ca44d646e5dca8 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Mon, 13 Jan 2020 16:44:44 -0500 Subject: [PATCH 1/2] it's safe for destroy provisioners to access path The path values are statically loaded, and do not create any dependencies that could cause problems with destroy provisioners. --- configs/provisioner.go | 2 +- configs/testdata/warning-files/destroy-provisioners.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/provisioner.go b/configs/provisioner.go index bbc6de993..9dee6e881 100644 --- a/configs/provisioner.go +++ b/configs/provisioner.go @@ -127,7 +127,7 @@ func onlySelfRefs(body hcl.Body) hcl.Diagnostics { for _, v := range attr.Expr.Variables() { valid := false switch v.RootName() { - case "self": + case "self", "path": valid = true case "count": // count must use "index" diff --git a/configs/testdata/warning-files/destroy-provisioners.tf b/configs/testdata/warning-files/destroy-provisioners.tf index ff950bc7f..96d8aafb5 100644 --- a/configs/testdata/warning-files/destroy-provisioners.tf +++ b/configs/testdata/warning-files/destroy-provisioners.tf @@ -12,7 +12,7 @@ resource "null_resource" "a" { when = destroy index = count.index key = each.key - + dir = path.module } } From 35107acc468e0b04ad75caa079660774581a004d Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 15 Jan 2020 11:39:01 -0500 Subject: [PATCH 2/2] allow "terraform" in destroy provisioners The values supplied in terraform are static, and do not create any dependencies. --- configs/provisioner.go | 2 +- configs/testdata/warning-files/destroy-provisioners.tf | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/configs/provisioner.go b/configs/provisioner.go index 9dee6e881..6f380860a 100644 --- a/configs/provisioner.go +++ b/configs/provisioner.go @@ -127,7 +127,7 @@ func onlySelfRefs(body hcl.Body) hcl.Diagnostics { for _, v := range attr.Expr.Variables() { valid := false switch v.RootName() { - case "self", "path": + case "self", "path", "terraform": valid = true case "count": // count must use "index" diff --git a/configs/testdata/warning-files/destroy-provisioners.tf b/configs/testdata/warning-files/destroy-provisioners.tf index 96d8aafb5..c6c28b823 100644 --- a/configs/testdata/warning-files/destroy-provisioners.tf +++ b/configs/testdata/warning-files/destroy-provisioners.tf @@ -12,7 +12,11 @@ resource "null_resource" "a" { when = destroy index = count.index key = each.key + + // path and terraform values are static, and do not create any + // dependencies. dir = path.module + workspace = terraform.workspace } }