Skip to content

Commit

Permalink
Merge pull request #2 from AndrewChubatiuk/spawn-process-for-ssh-tunnel
Browse files Browse the repository at this point in the history
Spawn process for ssh tunnel
  • Loading branch information
AndrewChubatiuk authored Dec 23, 2021
2 parents 41a7bbe + a13c624 commit fd1b05c
Show file tree
Hide file tree
Showing 16 changed files with 452 additions and 322 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.16
-
name: Import GPG key
id: import_gpg
Expand Down
47 changes: 0 additions & 47 deletions Makefile

This file was deleted.

50 changes: 10 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,22 @@
### terraform-provider-ssh

This provider enables SSH port forwarding in Terraform. It is intended as a
This experimental provider enables SSH port forwarding in Terraform. It is intended as a
bandaid [until it is supported in Terraform itself](https://github.com/hashicorp/terraform/issues/8367).

**Note: Terraform v0.12 support is highly experimental!**

#### Example

See [main.tf](main.tf).
See [main.tf](example/main.tf).

#### Installation

On Linux:

```shell
mkdir -p terraform.d/plugins/linux_amd64
wget https://github.com/stefansundin/terraform-provider-ssh/releases/download/v0.0.4/terraform-provider-ssh_v0.0.4_linux_amd64.zip
unzip terraform-provider-ssh_v0.0.4_linux_amd64.zip -d terraform.d/plugins/linux_amd64
rm terraform-provider-ssh_v0.0.4_linux_amd64.zip
terraform init
```

On Mac:

```shell
mkdir -p terraform.d/plugins/darwin_amd64
wget https://github.com/stefansundin/terraform-provider-ssh/releases/download/v0.0.4/terraform-provider-ssh_v0.0.4_darwin_amd64.zip
unzip terraform-provider-ssh_v0.0.4_darwin_amd64.zip -d terraform.d/plugins/darwin_amd64
rm terraform-provider-ssh_v0.0.4_darwin_amd64.zip
terraform init
```

#### Applying an output file

Note that there is a gotcha when trying to apply a generated plan output file (see [issue #1](https://github.com/stefansundin/terraform-provider-ssh/issues/1)). In this case, the SSH tunnels will not be automatically opened.

As a workaround, before you apply, run the companion program `terraform-open-ssh-tunnels` on the plan file first in order to reopen the SSH tunnels. [Download from the releases.](https://github.com/stefansundin/terraform-provider-ssh/releases/latest)

Because of [this commit](https://github.com/stefansundin/terraform-provider-ssh/commit/37fa9835b75fde095c863fca89e2f28a0169919d), only the SSH agent is currently supported in this program. Let me know if you can think of a good fix for this.

#### TODO

- Support another hop (ProxyJump-like behavior)
- Note that the Windows binary is completely untested!

#### Building
Provider can be automatically installed using Terraform >= 0.13 by providing a `terraform` configuration block:

```
$ go get -u github.com/golang/protobuf/protoc-gen-go
$ make
terraform {
required_providers {
ssh = {
source = "AndrewChubatiuk/ssh"
}
}
}
```
4 changes: 0 additions & 4 deletions example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ data "consul_keys" "keys" {
}
}

data "ssh_tunnel_close" "consul" {
depends_on = [data.consul_keys.keys]
}

output "local_address" {
value = data.ssh_tunnel.consul.local.0.host
}
Expand Down
32 changes: 23 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
module github.com/stefansundin/terraform-provider-ssh

go 1.15
go 1.16

require (
github.com/golang/protobuf v1.4.3 // indirect
github.com/hashicorp/hcl/v2 v2.8.2 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.4
github.com/zclconf/go-cty v1.7.1 // indirect
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-hclog v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/hcl/v2 v2.11.1 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
github.com/hashicorp/terraform-registry-address v0.0.0-20210816115301-cb2034eba045 // indirect
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
github.com/jinzhu/copier v0.3.4 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.43.0 // indirect
)
Loading

0 comments on commit fd1b05c

Please sign in to comment.