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 6d904003012..83093572697 100644 --- a/tests/integration/targets/ec2_eip/tasks/main.yml +++ b/tests/integration/targets/ec2_eip/tasks/main.yml @@ -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: