Unable to attach an EIP to a VPC Instance

280 views
Skip to first unread message

Stephen Nelson-Smith

unread,
Aug 3, 2017, 1:36:19 PM8/3/17
to Ansible Project


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<Response><Errors><Error><Code>InvalidParameterCombination</Code><Message>You must specify an allocation id when mapping an address to a VPC instance</Message></Error></Errors><RequestID>14ea5e22-0e38-4392-90bc-48c1837f4a46</RequestID></Response>"}


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.

Pshem Kowalczyk

unread,
Aug 3, 2017, 7:30:36 PM8/3/17
to Ansible Project
Hi,

Try specifying "private_ip_address" of the ENI that you're allocating elastic IP to.

kind regards
Pshem


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ce0ef404-3846-44ee-8f42-f56c267750c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Nelson-Smith

unread,
Aug 4, 2017, 1:40:51 AM8/4/17
to Ansible Project


On Friday, 4 August 2017 00:30:36 UTC+1, Pshem Kowalczyk wrote:
Hi,

Try specifying "private_ip_address" of the ENI that you're allocating elastic IP to.

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.

Stephen Nelson-Smith

unread,
Aug 4, 2017, 2:44:33 AM8/4/17
to Ansible Project
Hello all,


On Friday, 4 August 2017 06:40:51 UTC+1, Stephen Nelson-Smith wrote:

Will keep this thread updated.

Right, so the issue was that when the EIP is initially created it need to be specified as in_vpc.  If you create an EIP without specifying in_vpc, and then try to associate it with and instance, whilst specifying in_vpc, AWS complains because the IP you are trying to associate with the instance was not created in a VPC scope.

S.
Reply all
Reply to author
Forward
0 new messages