flaupretre/terraform-ssh-tunnel

what if existing connections with the same local mapping are forcefully closed once a new one opens

Opened this issue · 2 comments

atm i consider a local-exec to fish out the process, close it and reopen another tunnel based on the circumstance
that tools arent as dynamically configurable as id like them to be.

some resource:
https://unix.stackexchange.com/questions/389014/getting-a-pid-for-an-ssh-process-that-backgrounded-itself

i monkey patched the terraform process accordingly:

resource "null_resource" "worker1_tunnel_close" {
  depends_on = [ 
    talos_machine_configuration_apply.worker1
  ]

  provisioner "local-exec" {
    command = "pgrep -f \"ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -i ${var.proxmoxremotehostkeypath}\" | xargs kill"
  }
}

it might be easier to attach a generated unique id to the process (is that even possible?) and fetch it like this

a way to tell if the command has failed would be awesome as well.

maybe there is some overlap with this issue

Sorry, I don't understand the issue. Can you elaborate ?