# Unable to attach an EIP to a VPC Instance

**URL:** <https://forum.ansible.com/t/unable-to-attach-an-eip-to-a-vpc-instance/25177>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 3, 2017, 5:36pm UTC](https://forum.ansible.com/t/unable-to-attach-an-eip-to-a-vpc-instance/25177 "2017-08-03T17:36:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen\_Nelson-Smith](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@Stephen\_Nelson-Smith](https://forum.ansible.com/u/Stephen_Nelson-Smith)\
**Post date:** [August 3, 2017, 5:36pm UTC](https://forum.ansible.com/t/unable-to-attach-an-eip-to-a-vpc-instance/25177/1 "2017-08-03T17:36:19Z")

</div>

I’m trying to attach an elastic IP to an instance in a VPC, but despite following what seem to be working examples in online documentation, I’m getting an error.

To keep it as simple as possible, I have:

- Launched an instance (using Ansible) in a public VPC subnet

- Manually captured its ID

- Created an elastic IP (using Ansible)

- Manually captured its ID

I’ve then placed these two into the following:

- ec2\_eip:

in\_vpc: yes

aws\_access\_key: “{{ aws\_access\_key }}”

aws\_secret\_key: “{{ aws\_secret\_key }}”

region: “{{ aws\_region }}”

ip: 176.34.177.168

device\_id: i-017a9496dc9940cd1

The output I get is:

fatal: [localhost]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “EC2ResponseError: 400 Bad Request\n\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>\n`InvalidParameterCombination`You must specify an allocation id when mapping an address to a VPC instance14ea5e22-0e38-4392-90bc-48c1837f4a46”}

I get the same behaviour when I tie the above tasks together with register and facts.

Having scoured the documentation, mailing lists, online books, and other Google resources, I can’t see that I am doing anything wrong.

What am I missing?

My system:

$ lsb\_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 16.04.2 LTS

Release: 16.04

Codename: xenial

$ ansible --version

ansible 2.3.1.0

config file =

configured module search path = Default w/o overrides

python version = 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609]

S.

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [August 3, 2017, 11:30pm UTC](https://forum.ansible.com/t/unable-to-attach-an-eip-to-a-vpc-instance/25177/2 "2017-08-03T23:30:10Z")

</div>

Hi,

Try specifying “private\_ip\_address” of the ENI that you’re allocating elastic IP to.

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![Stephen\_Nelson-Smith](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@Stephen\_Nelson-Smith](https://forum.ansible.com/u/Stephen_Nelson-Smith)\
**Post date:** [August 4, 2017, 5:40am UTC](https://forum.ansible.com/t/unable-to-attach-an-eip-to-a-vpc-instance/25177/3 "2017-08-04T05:40:51Z")

</div>

Thanks - I have added that line, but the outcome is the same. For clarity, I have not created an EIN - I’m just using the interface on the instance, but I don’t think that’s an issue at all.

I’m going to check if I’m using the very latest boot, and also try doing this in boto directly - if the issue is in boto directly (and the message looks like a boto message, having looked at the src), then it’s not strictly an Ansible issue, so I’ll raise it directly.

Will keep this thread updated.

S.

---

<div class="post-metadata">

**Author:** ![Stephen\_Nelson-Smith](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@Stephen\_Nelson-Smith](https://forum.ansible.com/u/Stephen_Nelson-Smith)\
**Post date:** [August 4, 2017, 6:44am UTC](https://forum.ansible.com/t/unable-to-attach-an-eip-to-a-vpc-instance/25177/4 "2017-08-04T06:44:32Z")

</div>

Hello all,
