Skip to content

Commit

Permalink
Default to port 22.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Nov 25, 2017
1 parent 759655c commit d66f434
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions data_source_ssh_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"log"
"net"
"strings"

"github.com/hashicorp/terraform/helper/schema"
"golang.org/x/crypto/ssh"
Expand Down Expand Up @@ -80,6 +81,11 @@ func dataSourceSSHTunnelRead(d *schema.ResourceData, meta interface{}) error {
remoteAddress := d.Get("remote_address").(string)
tunnelEstablished := d.Get("tunnel_established").(bool)

// default to port 22 if not specified
if !strings.Contains(host, ":") {
host = host + ":22"
}

log.Printf("[DEBUG] user: %v", user)
log.Printf("[DEBUG] host: %v", host)
log.Printf("[DEBUG] localAddress: %v", localAddress)
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
data "ssh_tunnel" "consul" {
user = "stefan"
host = "bastion.example.com:22"
host = "bastion.example.com"
private_key = "${file(pathexpand("~/.ssh/id_rsa"))}"
local_address = "localhost:8500"
remote_address = "localhost:8500"
Expand Down

0 comments on commit d66f434

Please sign in to comment.