Giter VIP home page Giter VIP logo

lambda-sync-private-elb-ips's Introduction

AWS Lambda example to check if ELB private IPS are changed

Based on NodeJS

Summary

This Lambda function allows you to use an AWS ELB (application loadbalancer) that is configured as a public loadbalancer to also balance private loads by keeping the private IPS up to date in a Route53 record. Run this lambda function every x minutes to check if the IPs of the loadbalancers changed (by checking network interfaces). It updates the event parameters to save the last status and when IPs changed, it will update the specified Route53 record.

Deploy

To use this plugin:

  • set parameters at the top of index.js file
  • Clone this repo: git clone
  • npm install
  • run npm run createzip to create a zipfile with all content to upload to Lambda
  • create a function on AWS for Lambda and update the zip file
  • create an event that runs the lambda function every x minutes (make sure the name of the event matches the parameter in index.js)

Notice: The first times it will run slow and take about 3seconds to complete. This drops to 300ms after a few executions.

IAM Setting

Besides the normal Lambda policy to write to CloudWatch logs, you also need the following policy: (Replace ACCOUNTID with your accountid, ZONEID with the route53 zone and FUNCTIONNAME with the name of the lambda function)

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "ec2:DescribeNetworkInterfaces",
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "events:PutTargets",
                "route53:ChangeResourceRecordSets",
                "events:ListTargetsByRule"
            ],
            "Resource": [
                "arn:aws:events:*:_ACCOUNTID_:rule/_FUNCTIONNAME_",
                "arn:aws:route53:::hostedzone/_ZONEID_"
            ]
        }
    ]
}

lambda-sync-private-elb-ips's People

Contributors

bramzor 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.