builder/amazon/common: SSH into private IP if in VPC
This commit is contained in:
parent
dd1c4d4d2a
commit
110fd0e17f
|
@ -11,8 +11,15 @@ import (
|
|||
// for determining the SSH address based on the instance DNS name.
|
||||
func SSHAddress(port int) func(map[string]interface{}) (string, error) {
|
||||
return func(state map[string]interface{}) (string, error) {
|
||||
var host string
|
||||
instance := state["instance"].(*ec2.Instance)
|
||||
return fmt.Sprintf("%s:%d", instance.DNSName, port), nil
|
||||
if instance.VpcId != "" {
|
||||
host = instance.PrivateIpAddress
|
||||
} else {
|
||||
host = instance.DNSName
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s:%d", host, port), nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue