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

Allow filtering EIPs by AWS tag (New --tag parameter) #40

Closed
wants to merge 1 commit into from

Conversation

hmmmsausages
Copy link
Contributor

This PR, I believe, fixes: #31

Summary:

Simple feature addition, as I was facing the same issue as described in #31.
Basically I was having a similar issue, where it would be of advantage to simply assign EIPs from a pool of EIPs that have a specific AWS tag (for example Group=prod-eips) instead of specifiying the IPs directly, which would require in my case EC2 launch configuration / CloudFormation template updates every time I would add or remove new EIPs.

Usage:

The tag approach works pretty well in conjunction with auto-scaling groups.
For example execute the script during the start-up of the EC2 instance via UserData or cfn-init helper scripts, like so:

pip install aws-ec2-assign-elastic-ip
aws-ec2-assign-elastic-ip --tag Group=prod-eips >> /var/log/aws-ec2-assign-elastic-ip.log

This then allows me to manage the allocated EIPs on AWS by adding or removing a tag with the key Group and the value prod-eips. Thus when I have the need to scale up my EC2 instances, I simply make sure I have enough EIPs with the correct tag available and then perform the scaling operation without updating the EC2 launch configuration.

If I want I can narrow down the eligible EIPs by still providing --valid-ips and --invalid-ips in addition to --tag as before.

@sebdah Let me know what you think. I'm not the greatest Python dev, so feel free to refactor it, but I think this could be useful for others as well (like #31 - even though it's coming one and half years too late for him, I suppose) :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assign from a pool of EIP
1 participant