aws-ec2-assign-elastic-ip
aws-ec2-assign-elastic-ip copied to clipboard
disassociate_first optional flag
Feature request: There are several use cases where it is desirable that a newly launched instance can be guaranteed to have/steal an address from a pool of existing addresses that may all be attached. Our use cases is rolling docker deployments. #15 is similar.
A flag like "disassociate_first" that will simply perform a disassociate call on the elastic IP http://docs.aws.amazon.com/cli/latest/reference/ec2/disassociate-address.html before trying to acquire the address would seemingly solve our problem. If the flag is false by default it shouldn't be an issue to any existing users.
Looking for same feature.
AWS CLI has flag called --allow-reassociation which is auto deassociate desired IP from any other EC2
aws ec2 associate-address --instance-id=$EC2INSTANCE_ID --allocation-id=$EIPALLOC_ID --allow-reassociation --region=$EC2REGION
is there any update on this? If no-one is planning or currently working on it - I could contribute a PR for this. Please let me know. Thanks!
@ankitcha No active work ongoing for this one. Please submit a PR. I'd be happy to review and merge.
I need this too. I will submit a PR.
Hi Sebastian,
How I need to run this code in Lambda ? My task is to attach EIP's to newly launched instances, I've setup the Auto Scaling Group and created the Life Cycle Hooks. But how can I put this code in Lambda ?
With boto3 in master, I've put up a branch that adds support for controlling AllowReassociation via a CLI flag:
https://github.com/pmkane/aws-ec2-assign-elastic-ip/tree/allow_reassociation
Currently, it does not prefer to assign unassociated IPs, in the case that multiple IPs are available for association. This meets our internal requirements, but I imagine could be surprising behavior if someone runs the command without any command-line requirements.
In our own use case, we would only use --allow-reassociation in combination with --valid-ips with a single IP specified. If that fit other folks' requirements too, we could enforce that policy in the tool.
Thoughts @sebdah or others?
@pmkane I think there is a clear use case for --allow-reassociation (false by default). Your use case with --valid-ips is likely the most common and least dangerous one. But I'm not so sure we should limit the tool to that requirement.
However, maybe a safe behavior would be to enforce --valid-ips in the normal use case and add a --force flag to override that check?
Happy to review / merge etc, so feel free to submit a PR.
In addition to :point_up:, #40 is adding a flag --tag which should probably also be considered along with --valid-ips.
Thanks @sebdah , agreed with all. If the PR for #40 is going to be merged soon, I will wait until that happens and then submit a PR. If not, I'll go ahead now.
:+1: I think you can go ahead :bow:, there's some work to get #40 ready for merging.