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\"?>\nInvalidNetworkInterfaceId.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
What am I doing wrong? Do I have to somehow token-ize the ec2_instance_ids?
Thanks!