ec2_eip and device_id

59 views
Skip to first unread message

Robert Haskins

unread,
Dec 15, 2016, 11:16:17 PM12/15/16
to Ansible Project
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<Response><Errors><Error><Code>InvalidNetworkInterfaceId.Malformed</Code><Message>Invalid id: \"['i-077050831eb30d9da']\" (expecting \"eni-...\")</Message></Error></Errors><RequestID>d13bc6c2-ee3a-48ed-8e64-a84caea7bbfc</RequestID></Response>"
}

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:


What am I doing wrong? Do I have to somehow token-ize the ec2_instance_ids?

Thanks!
Reply all
Reply to author
Forward
0 new messages