# ec2\_eip and device\_id

**URL:** <https://forum.ansible.com/t/ec2-eip-and-device-id/23270>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [December 16, 2016, 4:16am UTC](https://forum.ansible.com/t/ec2-eip-and-device-id/23270 "2016-12-16T04:16:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Haskins](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@Robert\_Haskins](https://forum.ansible.com/u/Robert_Haskins)\
**Post date:** [December 16, 2016, 4:16am UTC](https://forum.ansible.com/t/ec2-eip-and-device-id/23270/1 "2016-12-16T04:16:17Z")

</div>

I am trying to assign a single elastic IP to a single AWS instance using this:

- name: associate an assigned IP with a running instance  
ec2\_eip:  
region: “{{ aws\_region }}”  
ip: “{{ eip.public\_ip }}”  
device\_id: “{{ ec2.instance\_ids }}”  
register: eip

This is what I am getting back for a response:

fatal: [localhost]: FAILED! =\> {  
“changed”: false,  
“failed”: true,  
“invocation”: {  
“module\_args”: {  
“aws\_access\_key”: null,  
“aws\_secret\_key”: null,  
“device\_id”: “[‘i-077050831eb30d9da’]”,  
“ec2\_url”: null,  
“in\_vpc”: false,  
“ip”: “34.195.37.120”,  
“profile”: null,  
“public\_ip”: “34.195.37.120”,  
“region”: “us-east-1”,  
“release\_on\_disassociation”: false,  
“reuse\_existing\_ip\_allowed”: false,  
“security\_token”: null,  
“state”: “present”,  
“validate\_certs”: true,  
“wait\_timeout”: “300”  
},  
“module\_name”: “ec2\_eip”  
},  
“msg”: “EC2ResponseError: 400 Bad Request\n\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>\n`InvalidNetworkInterfaceId.Malformed`Invalid id: "[‘i-077050831eb30d9da’]" (expecting "eni-…")d13bc6c2-ee3a-48ed-8e64-a84caea7bbfc”  
}

The error coming back from AWS seems to indicate device\_id is expecting a eni, but the docs clearly say that device\_id can be an EC2 instance ID:

[http://docs.ansible.com/ansible/ec2\_eip\_module.html#options](http://docs.ansible.com/ansible/ec2_eip_module.html#options)

What am I doing wrong? Do I have to somehow token-ize the ec2\_instance\_ids?

Thanks!
