flaupretre/terraform-ssh-tunnel

Issues with tunnel when a change is expected in a module the tunnel depends on

Closed this issue · 1 comments

I'm having problems with this tunnel. Here is the (simplified) configuration I have:

module "bastion" {}
module "postgres" {}

module "postgres_tunnel" {
  source     = "flaupretre/tunnel/ssh"
  version    = "1.9.0"
  depends_on = [module.postgres, module.bastion]

  gateway_host = module.bastion[0].public_dns
  target_host  = module.postgres[0].cluster_endpoint
  [...]
}

module "postgres_resources" {
  depends_on    = [module.postgres_tunnel, module.bastion, module.postgres]
  postgres_host = module.postgres_tunnel.host
  postgres_port = module.postgres_tunnel.port
  [...]
}

When I add a new resource to the postgres module, I get the following errors in plan mode when Terraform tries to refresh the state of resources in the postgres_resources module:

Error: dial tcp 127.0.0.1:0: connect: connection refused

When I remove the new resource (just a dummy random_password resource), the plan mode passes refreshing the state of the resources in the postgres_resources module (contains things like postgres roles, databases, schemas, etc.)

Well... I don't know why or how, but removing the depends_on from the postgres, postgres_tunnel and postgres_resources modules fixes the issue.