Skip to main content

Automatically assign Elastic IPs to AWS EC2 instances

Project description

aws-ec2-assign-elastic-ip
=========================

Automatically assign Elastic IPs to AWS EC2 instances. This can be really nice in auto scaling groups were you need to communicate the external IP's to third party systems.

The script should be executed on the EC2 instance that should get assigned an Elastic IP. This is typically done as part of the instance boot process.

`aws-ec2-assign-elastic-ip` is idempotent and will not assign an new Elastic IP if the instance already has one.

Installation
------------

`aws-ec2-assign-elastic-ip` is easiest to install via PyPI.

pip install aws-ec2-assign-elastic-ip

Configuration options
---------------------

The script is configured using command line options. You can provide your AWS credentials directly on the command line, but the script also supports all [boto credential config options](http://boto.readthedocs.org/en/latest/boto_config_tut.html#credentials).

usage: aws-ec2-assign-elastic-ip [-h] [--version] [--region REGION]
[--access-key ACCESS_KEY]
[--secret-key SECRET_KEY]
[--valid-ips VALID_IPS]

Assign EC2 Elastic IP to the current instance

optional arguments:
-h, --help show this help message and exit
--version Print the Automated EBS Snapshots version and exit
--region REGION AWS region. Default: us-east-1
--access-key ACCESS_KEY
AWS access key ID
--secret-key SECRET_KEY
AWS secret access key ID
--valid-ips VALID_IPS
A comma separated list of valid Elastic IPs. Default
is to try all IPs. Example:
56.123.56.123,56.123.56.124,56.123.56.125

The `--valid-ips` option require the public IPs in a comma separated sequence. E.g. `56.123.56.123,56.123.56.124,56.123.56.125`.

Supported platforms
-------------------

The `aws-ec2-assign-elastic-ip` should work fine on Linux, Mac OS X and Microsoft Windows. Please submit an issue if you have any issues with any of the platforms.

Required IAM permissions
------------------------

**Community contribution much appreciated on this!**

We have been using the following IAM policys to be able to list and associate Elastic IPs. This can probably be narrowed down abit. It allows EC2 read-only (from the IAM wizard) and `ec2:AssociateAddress` permissions:

"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:AssociateAddress",
"ec2:Describe*"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "elasticloadbalancing:Describe*",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"cloudwatch:ListMetrics",
"cloudwatch:GetMetricStatistics",
"cloudwatch:Describe*"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "autoscaling:Describe*",
"Resource": "*"
}
]

License
-------

APACHE LICENSE 2.0

Copyright 2014 Skymill Solutions

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-ec2-assign-elastic-ip-0.2.0a1.tar.gz (10.8 kB view details)

Uploaded Source

File details

Details for the file aws-ec2-assign-elastic-ip-0.2.0a1.tar.gz.

File metadata

File hashes

Hashes for aws-ec2-assign-elastic-ip-0.2.0a1.tar.gz
Algorithm Hash digest
SHA256 230fd5c8f59c4f56fa6c89d36e1d2db2c7da1a1b3000cb4a22da8f2a545a3c5d
MD5 7efbb482db4ba0137ad7d524b6bc16dd
BLAKE2b-256 920e2a08c9d709a96dfd2a83b9b13292549e0c346670d50252f6131fec35345b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page