flaupretre/terraform-ssh-tunnel

Terraform destroy won't create tunnel

Closed this issue · 1 comments

Description

The tunnel is opened and closed as expected for terraform apply. But terraform destroy won't create the tunnel, which can be checked by watch -n 1 'netstat -tulnp | grep ssh'.

Workaround

Tunnel must be started separately and then the local port passed to terraform. E.g. terraform destroy -var='db_tunnel_local_port=5432'. Postgresql provider port then looks like: port = var.db_tunnel_local_port != null ? var.db_tunnel_local_port : module.db_tunnel.port.

Is there a way to achieve the same behavior with delete as with apply?

I am sorry but I tried to reproduce the issue and destroy works fine for me and creates the tunnel as required (when refreshing resource state). I run 'terraform destroy' and, when it asks for a value, I run 'netstat -a | grep -w ssh' in another windows. And I get this :

tcp 0 0 indy:40322 ec2-34-242-178-191.:ssh ESTABLISHED

which shows that the tunnel is open.