Unable to attach an EIP to a VPC Instance

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\"?>\nInvalidParameterCombinationYou 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.

Hi,

Try specifying “private_ip_address” of the ENI that you’re allocating elastic IP to.

kind regards
Pshem

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.

Hello all,