# Enhance ec2\_eip to optionally prevent reassociation

**URL:** <https://forum.ansible.com/t/enhance-ec2-eip-to-optionally-prevent-reassociation/20310>\
**Category:** Ansible Developer\
**Tags:** aws\
**Created:** [January 22, 2016, 3:16am UTC](https://forum.ansible.com/t/enhance-ec2-eip-to-optionally-prevent-reassociation/20310 "2016-01-22T03:16:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh\_Smift1](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Josh\_Smift1](https://forum.ansible.com/u/Josh_Smift1)\
**Post date:** [January 22, 2016, 3:16am UTC](https://forum.ansible.com/t/enhance-ec2-eip-to-optionally-prevent-reassociation/20310/1 "2016-01-22T03:16:22Z")

</div>

We want to use the ec2\_eip module to associate an EIP with the instance  
that should have it (a proxy server, say), but only if the EIP is  
currently unassociated; if we accidentally bring up another instance that  
looks like the proxy server in the relevant ways, we don't want it to  
steal the EIP from the first one.

Looking at [https://docs.aws.amazon.com/cli/latest/reference/ec2/associate-address.html](https://docs.aws.amazon.com/cli/latest/reference/ec2/associate-address.html),  
I see that there are --allow-reassociation and --no-allow-reassociation  
options to control this.

Looking at [https://docs.ansible.com/ansible/ec2\_eip\_module.html](https://docs.ansible.com/ansible/ec2_eip_module.html), it looks  
like the Ansible ec2\_eip module doesn't already have this.

Looking at [https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API\_AssociateAddress.html](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssociateAddress.html),  
it looks like the AllowReassociation request parameter could control this,  
so adding support for this to ec2\_eip, e.g. via a new optional  
allow\_reassociation parameter, seems like it'd be pretty straightforward.

Does this seem like a good approach? If so, I'll try to do it, unless  
anyone else would rather. :^)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Josh (jbs@care.com)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

---

<div class="post-metadata">

**Author:** ![Adam\_Hamsik](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@Adam\_Hamsik](https://forum.ansible.com/u/Adam_Hamsik)\
**Post date:** [January 22, 2016, 11:11am UTC](https://forum.ansible.com/t/enhance-ec2-eip-to-optionally-prevent-reassociation/20310/2 "2016-01-22T11:11:15Z")

</div>

Hi,

in general yes. But ec2\_eip module is using boto library so you’ll have to use that one to propagate allow\_reassociation to aws.
