Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple tunnels #8

Open
chrs-myrs opened this issue Oct 7, 2022 · 1 comment
Open

Multiple tunnels #8

chrs-myrs opened this issue Oct 7, 2022 · 1 comment

Comments

@chrs-myrs
Copy link

Yours is the most reliable SSH tunnel for terraform, but was very sad when I tried to add a second tunnel

Affected Resource(s)

  • ssh_tunnel

Terraform Configuration Files

terraform {
  required_version = ">= 1.0.9"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
    ssh = {
      source  = "AndrewChubatiuk/ssh"
      version = "0.1.5"
    }
    mysql = {
      source  = "petoju/mysql"
      version = "3.0.18"
    }
    redshift = {
      source = "brainly/redshift"
      version = "1.0.2"
    }
  }
  
  backend "s3" {
...
  }
}

provider "aws" {
...
}

provider "ssh" {}

data "ssh_tunnel" "mysql" {
  user = var.bastion_username
  auth {
    private_key {
      content = file(pathexpand("~/.ssh/id_rsa"))
    }
  }
  server {
    host = "---"
  }
  remote {
    host = "rds.${local.env}.local"
    port = 3306
  }
}

provider "mysql" {
  endpoint = data.ssh_tunnel.mysql.local.0.address
  username = "${local.env}_master"
  password = data.aws_ssm_parameter.cluster_password.value
  tls      = false
}

data "aws_ssm_parameter" "cluster_password" {
  name            = "---"
  with_decryption = true
}

data "ssh_tunnel" "redshift" {
  user = var.bastion_username
  auth {
    private_key {
      content = file(pathexpand("~/.ssh/id_rsa"))
    }
  }
  server {
    host = "bastion.---"
  }
  local {
    port = 5439
  }
  remote {
    host = "redshift.---"
    port = 5439
  }
}

Expected Behavior

Open two tunnels

Actual Behavior

Fail with rror: rpc: service already defined: SSHTunnelServer

Steps to Reproduce

  1. Add two ssh_tunnel data blocks
@chrs-myrs chrs-myrs changed the title Multiple tunnles Multiple tunnels Oct 8, 2022
@AndrewChubatiuk
Copy link
Owner

Added ability to run multiple tunnels in v0.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants