Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eip association when both instance id and private ip address are passed #328

Merged
merged 3 commits into from Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -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:
Expand Down