Allow filtering EIPs by AWS tag (New --tag parameter) #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
orcfn-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 valueprod-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