GithubHelp home page GithubHelp logo

fim / ec2ddns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dcarley/ec2ddns

0.0 1.0 0.0 116 KB

Python utlity to register an EC2 instance's hostname in Route 53

License: MIT License

Python 100.00%

ec2ddns's Introduction

ec2ddns

Python utlity to register an EC2 instance's hostname in Route 53.

Usage

Register an instance:

/usr/bin/python /usr/sbin/ec2ddns.py -k ${AWS_KEY} -s ${AWS_SECRET} ${DESIRE_HOSTNAME} ${PUBLIC_HOSTNAME}

Unregister an instance:

/usr/bin/python /usr/sbin/ec2ddns.py -k ${AWS_KEY} -s ${AWS_SECRET} ${DESIRE_HOSTNAME} --delete

IAM policy

Create a new IAM user and policy using Fog:

require 'fog'
require 'pp'

@username = "ec2ddns"
@zone_id  = "XXX"

iam   = Fog::AWS::IAM.new()
user  = iam.create_user(@username)
keys  = iam.create_access_key("UserName" => @username)

pp keys.body["AccessKey"]
access_key_id     = keys.body["AccessKey"]["AccessKeyId"]
secret_access_key = keys.body["AccessKey"]["SecretAccessKey"]

policy_statement = {
  "Statement" => [
    {
      "Effect" => "Allow",
      "Action" => ["route53:ListHostedZones"],
      "Resource" => "*"
    },
    {
      "Effect" => "Allow",
      "Action" => [
         "route53:GetHostedZone",
         "route53:ListResourceRecordSets",
         "route53:ChangeResourceRecordSets"
       ],
      "Resource" => "arn:aws:route53:::hostedzone/" + @zone_id
    },
    {
      "Effect" => "Allow",
      "Action" => ["route53:GetChange"],
      "Resource" => "arn:aws:route53:::change/*"
    }
  ]
}

iam.put_user_policy(@username, @username, policy_statement)

TODO

  • Use ~/.boto credentials or user-data directly if not provided by CLI args.
  • Better logging.
  • Restrict record types to A|CNAME when deleting conflicting records?
  • Store SSH fingerprints in DNS.
  • Better permissions or logic for deletion of other records:
    • If another machine legitimately has that hostname.
    • Malicious deletion of another instance's record.

ec2ddns's People

Contributors

dcarley avatar

Watchers

 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.