Skip to content

Commit

Permalink
Fix eip association when both instance id and private ip address are …
Browse files Browse the repository at this point in the history
…passed (ansible-collections#328)

* Fix ec2_eip with both instance_id and private_ip_address
* Add changelog fragment for the ec2_eip fix
  • Loading branch information
Phoosha committed Dec 15, 2020
1 parent 1afa13c commit d9c0c1f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
@@ -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).
2 changes: 1 addition & 1 deletion plugins/modules/ec2_eip.py
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/targets/ec2_eip/tasks/main.yml
Expand Up @@ -571,6 +571,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 instance
ec2_instance:
Expand Down

0 comments on commit d9c0c1f

Please sign in to comment.