Skip to content

Unable to update or destroy a terraform when utilizing execution_cmd.  #252

Open
@jeffellin

Description

@jeffellin

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

  1. Create a terraform script that provisions an attached cluster
  2. output the execution_cmd to the remote exec provisioner.
  3. Works first time,
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions