terraform-provider-tanzu-mission-control
terraform-provider-tanzu-mission-control copied to clipboard
Unable to update or destroy a terraform when utilizing execution_cmd.
Describe the bug
Error: Missing map element
│
│ on main.tf line 4, in module "ubuntu_node":
│ 4: execution_cmd=tanzu-mission-control_cluster.attach_cluster_without_apply.status.execution_cmd
│ ├────────────────
│ │ tanzu-mission-control_cluster.attach_cluster_without_apply.status is map of string with 9 elements
│
│ This map does not have an element with the key "execution_cmd".
This is what I got, thats producing that error.
module "ubuntu_node" {
source = "../ubuntu_node"
hostname="tap-run-1"
execution_cmd=tanzu-mission-control_cluster.attach_cluster_without_apply.status.execution_cmd
}
and in the module
provisioner "remote-exec" {
inline = [
"/bin/bash -c \"timeout 300 sed '/finished-user-data/q' <(tail -f /var/log/cloud-init-output.log)\"",
"export KUBECONFIG=/home/ubuntu/.kube/config",
"${var.execution_cmd}"
]
}
Reproduction steps
- Create a terraform script that provisions an attached cluster
- output the execution_cmd to the remote exec provisioner.
- Works first time,
- Terraform UPDATE or DELETE does not work. ...
Expected behavior
rerunning terraform should not result in an error due to missing execution_cmd.
the status map that is returned when looking up the resource does not return this value after the cluster is attached.
workaround for me was to use
lookup(tanzu-mission-control_cluster.attach_cluster_without_apply.status,"execution_cmd","unkown")
If this is working as designed please provide working example of attaching a cluster after provisioning it.
Additional context
No response