Commit 13f55bde authored by Nathan Sullivan's avatar Nathan Sullivan

working AssociatePublicIpAddress support

parent 5cbff00a
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/communicator/ssh" "github.com/mitchellh/packer/communicator/ssh"
"time" "time"
"log"
) )
// SSHAddress returns a function that can be given to the SSH communicator // SSHAddress returns a function that can be given to the SSH communicator
...@@ -20,7 +21,14 @@ func SSHAddress(e *ec2.EC2, port int) func(multistep.StateBag) (string, error) { ...@@ -20,7 +21,14 @@ func SSHAddress(e *ec2.EC2, port int) func(multistep.StateBag) (string, error) {
if i.DNSName != "" { if i.DNSName != "" {
host = i.DNSName host = i.DNSName
} else if i.VpcId != "" { } else if i.VpcId != "" {
host = i.PrivateIpAddress log.Printf("public ip from SSHAddress: %s", i.PublicIpAddress)
if i.PublicIpAddress != "" {
log.Printf("using public ip in SSHAddress")
host = i.PublicIpAddress
} else {
log.Printf("using private ip in SSHAddress")
host = i.PrivateIpAddress
}
} }
if host != "" { if host != "" {
......
...@@ -110,6 +110,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi ...@@ -110,6 +110,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
} }
s.instance = latestInstance.(*ec2.Instance) s.instance = latestInstance.(*ec2.Instance)
log.Printf("Public IP: %s", s.instance.PublicIpAddress)
if s.Debug { if s.Debug {
if s.instance.DNSName != "" { if s.instance.DNSName != "" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment