GithubHelp home page GithubHelp logo

chafouin / aws-lambda-asg-ddns Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 2.0 18 KB

AWS Lambda function to update a Route53 record with the IP addresses of EC2 instances contained in an AutoScaling Group

License: GNU General Public License v3.0

Makefile 7.75% Python 54.25% HCL 29.79% Shell 8.21%

aws-lambda-asg-ddns's Introduction

asg-ddns AWS Lambda function

Description

AWS Lambda function use to update a Route53 DNS record with the ip addresses of all the instances of an AutoScaling Group. If an instance joins the ASG, its IP will be added to the DNS record. If an instance is terminated, its IP will be removed to the DNS record. The ASG will send a notification to an SNS topic that will trigger this lambda function.

Dependencies

  • Python 3.4+
  • boto3

Deployment

The lambda IAM role must have at least the following policy attached:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "arn:aws:logs:*:*:*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "autoscaling:DescribeAutoScalingGroups"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ec2:DescribeInstances"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "route53:ListResourceRecordSets",
                "route53:ChangeResourceRecordSets"
            ],
            "Resource": "arn:aws:route53:::hostedzone/*",
            "Effect": "Allow"
        }
    ]
}

A Terraform template is provided if you want to try it out. It will deploy a SNS topic and the lambda function. You can then edit an existing AutoScaling group to send notification to the SNS topic when an instance is created or deleted.

A test script is provided to try the lambda function after deployment, sending a SNS notification on behalf of an AutoScaling Group.

./test.sh launch <sns_topic_arn> <asg_name>

aws-lambda-asg-ddns's People

Contributors

chafouin avatar reedstrm avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aws-lambda-asg-ddns's Issues

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.