Giter Site home page Giter Site logo

aws-sd-lambda's Introduction

AWS Service Discovery Lambda

This short script will watch your ASGs for Launch and Terminate events and allow you to register and deregister those EC2 instances based on tags you have given to them.

This only supports Route53 IP Address service discovery at the moment.

How it works

The function lists off the tags of the EC2 instance that is being brought online or terminated, looks for a tag or tags that are in the format:

TAG_PREFIX/NAMESPACE: SERVICE
or
TAG_PREFIX/NAMESPACE: SERVICE1, SERVICE2, ...

Then matches those tags to the Namespace, and Service to register against.

You pass an env var to the lambda function that is the prefix this function will look for, as TAG_PREFIX=PREFIX, do not add the trailing /.

IAM Roles

Only a few roles are needed for this script:

  • AmazonEC2ReadOnlyAccess
  • AWSCloudMapFullAccess
  • CloudWatchLogsFullAccess

CloudWatch event streams

You will need to watch a couple of Auto Scaling events, specifically:

  • EC2 Instance Launch Successful
  • EC2 Instance Terminate Successful

Build

The included Makefile has a package target which will build and zip the script for you to upload to AWS Lambda. The Function to target is Handler.

Some gotchas

  • Only supports Route53 IP, or A record discovery
  • If you have more than 100 Namespaces this currently will have a chance to fail
  • If you have more than 100 Services in a Namespace this could also fail
  • The error logging isn't great

aws-sd-lambda's People

Contributors

heschlie avatar

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.