-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi @AndrewChubatiuk,
Thanks for this module, hoping to make it work over here!
Looks like the tunnel is closed from the Terraform side, about 1-3 seconds after being opened.
Logs: https://gist.github.com/thecadams/e3dc630cadadc9018946fef98aea26ca
Of particular interest in the tf log is this line:
�[0m�[1mdata.ssh_tunnel.bastion_ssh_tunnel: Read complete after 1s [id=localhost:26127]�[0m
I have a config similar to this:
terraform {
required_providers {
...
grafana = {
source = "grafana/grafana"
version = "~> 1.35.0"
}
ssh = {
source = "AndrewChubatiuk/ssh"
}
...
}
required_version = ">= 1.2.6"
}
data "ssh_tunnel" "bastion_ssh_tunnel" {
user = "terraform"
auth {
private_key {
content = var.bastion_ssh_private_key
}
}
server {
host = "bastion-test.revenuecat.com"
port = 222
}
remote {
host = "grafana.test.internal"
port = 3000
}
}
provider "grafana" {
auth = var.grafana_auth
url = "http://${data.ssh_tunnel.bastion_ssh_tunnel.local.0.host}:${data.ssh_tunnel.bastion_ssh_tunnel.local.0.port}"
}
module "rc_prometheus_test" {
source = "../../modules/rc_prometheus"
...
dashboards = {"uid1": some_dashbord_json_1, "uid2": some_dashboard_json_2}
...
providers {
grafana = grafana
}
}
The rc_prometheus module manages 1 grafana folder and several dashboards in that folder:
(in ../../modules/rc_prometheus/main.tf):
...
resource "grafana_folder" "dashboards" {
title = "Generated: DO NOT EDIT"
}
resource "grafana_dashboard" "dashboards" {
for_each = var.dashboards
folder = grafana_folder.dashboards.id
config_json = each.value
overwrite = true
}
Unfortunately despite the grafana provider getting the correct host and port, I get connection refused as it seems the connection shuts down too fast. I also tried using time_sleep resources and provisioners in various places, but nothing worked.
Expected Behavior
There should be a way to control when the tunnel closes.
Actual Behavior
Tunnel closes within 1-3 seconds, causing connection refused errors in the module.
Steps to Reproduce
Something like the config above should repro this.
Important Factoids
Looks like recent changes in this fork removed the "close connection" provider, maybe that should be reinstated to support this use case?
You'll also notice stuff in the logs like this, which is not related, it's because I moved the ssh tunnel out of the module since the previous apply:
2023-03-07T01:34:58.915Z [DEBUG] module.rc_prometheus_test.module.bastion_ssh_tunnel is no longer in configuration