From 7acce9dc1b51676b2a5757cf931d405a4360e13c Mon Sep 17 00:00:00 2001 From: Andreas Born Date: Thu, 10 Dec 2020 19:38:39 +0100 Subject: [PATCH 1/3] Fix ec2_eip with both instance_id and private_ip_address --- plugins/modules/ec2_eip.py | 2 +- tests/integration/targets/ec2_eip/tasks/main.yml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/modules/ec2_eip.py b/plugins/modules/ec2_eip.py index 6aa2a531069..54624f59182 100644 --- a/plugins/modules/ec2_eip.py +++ b/plugins/modules/ec2_eip.py @@ -241,7 +241,7 @@ def associate_ip_and_device(ec2, module, address, private_ip_address, device_id, AllowReassociation=allow_reassociation, ) if private_ip_address: - params['PrivateIPAddress'] = private_ip_address + params['PrivateIpAddress'] = private_ip_address if address['Domain'] == 'vpc': params['AllocationId'] = address['AllocationId'] else: diff --git a/tests/integration/targets/ec2_eip/tasks/main.yml b/tests/integration/targets/ec2_eip/tasks/main.yml index d296d0197bc..0ff192de920 100644 --- a/tests/integration/targets/ec2_eip/tasks/main.yml +++ b/tests/integration/targets/ec2_eip/tasks/main.yml @@ -569,6 +569,22 @@ - instance_eip is success - eip_info.addresses[0].allocation_id is defined - eip_info.addresses[0].instance_id == '{{ instance_info.instances[0].instance_id }}' + - name: Attach eip to an EC2 instance with private Ip specified + ec2_eip: + device_id: '{{ instance_info.instances[0].instance_id }}' + private_ip_address: '{{ instance_info.instances[0].private_ip_address }}' + state: present + release_on_disassociation: yes + register: instance_eip + - ec2_eip_info: + filters: + public-ip: '{{ instance_eip.public_ip }}' + register: eip_info + - assert: + that: + - instance_eip is success + - eip_info.addresses[0].allocation_id is defined + - eip_info.addresses[0].instance_id == '{{ instance_info.instances[0].instance_id }}' # ===================================================== - name: Cleanup IGW ec2_vpc_igw: From 6543c11cdfb6e29692e4f186563b11e3c0c0f80c Mon Sep 17 00:00:00 2001 From: Andreas Born Date: Thu, 10 Dec 2020 21:41:35 +0100 Subject: [PATCH 2/3] Add changelog fragment for the ec2_eip fix --- .../328-fix-ec2_eip-instance-id-private-ip-address.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml diff --git a/changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml b/changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml new file mode 100644 index 00000000000..eb44cc11cf0 --- /dev/null +++ b/changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml @@ -0,0 +1,2 @@ +bugfixes: + - ec2_eip - fix eip association by instance id & private ip address due to case-sensitivity of the ``PrivateIpAddress`` parameter (https://github.com/ansible-collections/community.aws/pull/328) From a9d08ee1f5bd1baf419ac703eee40be2318022a8 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Thu, 10 Dec 2020 22:18:49 +0100 Subject: [PATCH 3/3] Update changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml --- .../328-fix-ec2_eip-instance-id-private-ip-address.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml b/changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml index eb44cc11cf0..8701cdd8694 100644 --- a/changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml +++ b/changelogs/fragments/328-fix-ec2_eip-instance-id-private-ip-address.yml @@ -1,2 +1,2 @@ bugfixes: - - ec2_eip - fix eip association by instance id & private ip address due to case-sensitivity of the ``PrivateIpAddress`` parameter (https://github.com/ansible-collections/community.aws/pull/328) + - ec2_eip - fix eip association by instance id & private ip address due to case-sensitivity of the ``PrivateIpAddress`` parameter (https://github.com/ansible-collections/community.aws/pull/328).