GithubHelp home page GithubHelp logo

stopthatastronaut / aws-ec2-assign-elastic-ip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sebdah/aws-ec2-assign-elastic-ip

0.0 2.0 0.0 464 KB

Automatically assign Elastic IPs to AWS EC2 Auto Scaling Group instances

License: Apache License 2.0

Makefile 1.37% Python 98.63%

aws-ec2-assign-elastic-ip's Introduction

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 and AWS instance profiles.

usage: aws-ec2-assign-elastic-ip [-h] [--version] [--region REGION]
                                 [--access-key ACCESS_KEY]
                                 [--secret-key SECRET_KEY] [--dry-run]
                                 [--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
  --dry-run             Turn on dry run mode. No address will be assigned,
                        we will only print which we whould take
  --valid-ips VALID_IPS
                        A comma separated list of valid Elastic IPs.
                        You can use CIDR expressions to select ranges.
                        Valid examples:
                        - 58.0.0.0/8
                        - 123.213.0.0/16,58.0.0.0/8,195.234.023.0
                        - 195.234.234.23,195.234.234.24

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.

We currently support Python 2.6 and 2.7. Python 3 support is missing as boto only supports the 2.x series at the moment.

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.

aws-ec2-assign-elastic-ip's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.