jaysonsantos / terraform-provider-jumphost

Terraform provider for Hashicups demo app
7 stars 6 forks source link

provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" #5

Open shimulch opened 2 years ago

shimulch commented 2 years ago

I was trying to run the example provided in this repository. I've made two changes (full file attached) -

But I could not run a successful terraform apply. Seems like the ssh tunnel getting closed before using it?

Terraform Version

Terraform v1.0.8
on linux_amd64
+ provider registry.terraform.io/hashicorp/http v2.1.0
+ provider registry.terraform.io/jaysonsantos/jumphost v0.0.2

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

terraform {
  required_providers {
    jumphost = {
      source = "jaysonsantos/jumphost"
      version = "0.0.2"
    }
    http = {
      version = "~> 2.1"
      source  = "hashicorp/http"
    }
  }
}

provider "jumphost" {
  hostname = "localhost"
  username = "terraform"
  port     = 2222
  password = 1234
}

data "jumphost_ssh" "httpbin" {
  hostname = "httpbin.org"
  port     = "80"
}

data "http" "example" {
  url = "http://localhost:${data.jumphost_ssh.httpbin.local_port}/get"

  # Optional request headers
  request_headers = {
    Accept = "application/json"
  }
}

output "host" {
  value = jsondecode(data.http.example.body).headers.Host
}

output "body_response" {
  value = jsondecode(data.http.example.body)
}

Debug Output

TF_LOG=TRACE TF_LOG_PATH=log terraform apply
╷
│ Error: Error making request: Get "http://localhost:41183/get": dial tcp 127.0.0.1:41183: connect: connection refused
│ 
│   with data.http.example,
│   on main.tf line 26, in data "http" "example":
│   26: data "http" "example" {
│ 
╵

Full stack trace - https://gist.github.com/shimulch/2c296d4bbebdf3196532b8339859904a

Expected Behavior

It should connect to httpbin via ssh tunnel.

Actual Behavior

jumphost provider exited.

Steps to Reproduce

  1. Clone this repo
  2. Run docker-compose up -d
  3. Run ssh terraform@localhost -p 2222 to ensure the ssh service is up
  4. Run terraform init
  5. Run terraform apply