Packer: Support creation of elastic ip address for AWS non-default VPCs

Created on 31 Oct 2013  ยท  12Comments  ยท  Source: hashicorp/packer

At present when I try to use the amazon-ebs builder for a non-default VPC, the instance is provisioned with a private ip address which packer cannot ssh into (as there is no route to the private ipaddress from the host where packer is being invoked).

2013/10/31 13:50:54 ui: ==> amazon-ebs: Launching a source AWS instance...
2013/10/31 13:50:58 /home/anth/packer/packer-builder-amazon-ebs: 2013/10/31 13:50:58 instance id: i-404e780c
==> amazon-ebs: Waiting for instance (i-404e780c) to become ready...
2013/10/31 13:50:58 ui: ==> amazon-ebs: Waiting for instance (i-404e780c) to become ready...
2013/10/31 13:50:58 /home/anth/packer/packer-builder-amazon-ebs: 2013/10/31 13:50:58 Waiting for state to become: running
    amazon-ebs: Private IP: 192.168.167.142
2013/10/31 13:51:15 ui:     amazon-ebs: Private IP: 192.168.167.142
2013/10/31 13:51:26 /home/anth/packer/packer-builder-amazon-ebs: 2013/10/31 13:51:26 Waiting for SSH, up to timeout: 1m0s
==> amazon-ebs: Waiting for SSH to become available...
2013/10/31 13:51:26 ui: ==> amazon-ebs: Waiting for SSH to become available...
2013/10/31 13:51:32 /home/anth/packer/packer-builder-amazon-ebs: 2013/10/31 13:51:32 Opening conn for SSH to tcp 192.168.167.142:22

This results in failure every time.

Can an option be added which is similar to the aws.elastic_ip option within vagrant so that an elastic ip address is allocated to the new instance?

https://github.com/mitchellh/vagrant-aws/issues/18

cheers,
Anth

buildeamazon enhancement good first issue

Most helpful comment

Packer supports the associate_public_ip_address option which should fix this now.

All 12 comments

I think this is a decent request, so I've added a tag for it.

However, when building in a VPC, you should probably be connected to a VPN or through a bastion or something to avoid this issue.

+1 on this

This goes for Instance Store and EBS Instances.

The IP doesnt need to be an Elastic IP either, there is a flag to just assign a regular Instance Public IP in the AWS API also :)

+1 on this feature, would be extremely handy (just hit it myself).

Bastion host within the VPC would be a workaround here, there are scenarios where you want to run with a non-default VPC though without VPN back to another office (unique IP space internally etc).

Plus VPN from a laptop isn't available natively, would need to use something like http://wiki.strongswan.org/projects/strongswan/wiki/AwsVpc on an EC2 instance within the VPC to workaround it (in that case your basically creating another form of bastion host, just with a different network protocol in between really).

Looking into this. I see the first requirement being augmenting the goamz file ec2/ec2.go to add the API flag:

NetworkInterface.n.AssociatePublicIpAddress

As per http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-RunInstances.html

Then once this is exposed, we can set it via packer.

Sound logical?

OK I have this working now locally, I'll submit pull requests for goamz and packer shortly.

Note, this only adds support for AssociatePublicIpAddress, not Elastic IPs.

PR22 for goamz and PR660 above are good to go - please review @mitchellh :)

Note - Elastic IP Support has been added to goamz separately in https://github.com/mitchellh/goamz/pull/23 also (thanks @sorohan)

Packer supports the associate_public_ip_address option which should fix this now.

Does this mean elastic or just public IP?

It means (nat'ed) public IP, not EIP. If you need EIP use a user-script that attaches it and set ssh_host to the IP.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mwhooker picture mwhooker  ยท  3Comments

s4mur4i picture s4mur4i  ยท  3Comments

Nikoos picture Nikoos  ยท  3Comments

sourav82 picture sourav82  ยท  3Comments

DanielBo picture DanielBo  ยท  3Comments