title: How to delete vault secret using null resource in terraform
body: <p>@all</p>
  <p>I have written a code to create a vault secret using null_resource but I am getting one error when I run terraform validate</p>
  <pre><code>  provisioner &quot;local-exec&quot; {
      when = create
      command = &quot;curl -k -H 'X-Vault-Token: ${var.VAULT_TOKEN}' -X POST --data @$PWD/config/kubeconfig.json ${var.VAULT_ADDR}/v1/secret/aws/tsys${module.init.current_account_name_lower}/${local.region}/eks_linux/${local.cluster_name}/kubeconfig&quot;
    }
    depends_on = [
      null_resource.copy_kube_config
    ]
  }
  
  resource &quot;null_resource&quot; &quot;delete_vault_config&quot; {
    provisioner &quot;local-exec&quot; {
      when = destroy
      command = &quot;curl -k -H 'X-Vault-Token: ${var.VAULT_TOKEN}' -X DELETE ${var.VAULT_ADDR}/v1/secret/aws/vkhello${module.init.current_account_name_lower}/${local.region}/eks_linux/${local.cluster_name}/kubeconfig&quot;
    }
  }
  
  
  Error: Invalid reference from destroy provisioner
  │ 
  │   on main.tf line 42, in resource &quot;null_resource&quot; &quot;delete_vault_config&quot;:
  │   42:     command = &quot;curl -k -H 'X-Vault-Token: ${var.VAULT_TOKEN}' -X DELETE ${var.VAULT_ADDR}/v1/secret/aws/vkhello${module.init.current_account_name_lower}/${local.region}/eks_linux/${local.cluster_name}/kubeconfig&quot;
  │ 
  │ Destroy-time provisioners and their connection configurations may only reference attributes of the related resource, via 'self', 'count.index', or 'each.key'.
  │ 
  │ References to other resources during the destroy phase can cause dependency cycles and interact poorly with create_before_destroy.
  </code></pre>
  <p>Is there a way to delete the vault secret using null resource only when I run terraform destroy?</p>