Coder Social home page Coder Social logo

aws-lambda-stop-server's Introduction

AWS Lambda Stop Server Build Status

AWS Lambda function that will stop servers that have a tag with the key StopGroup and the value the name of the lambda function.

Usage

Download the zip file and deploy it as a lambda function.

After you deployed the lambda function, you navigate to Event sources and choose for the Scheduled Event. After naming your event, you can provide the following schedule expression.

cron(15 17 ? * MON-FRI *)

This expression wil stop the servers every weekday, from monday to friday, at 17:15 PM.

Tags

Tagging your instance is very important in order for the lambda function to work properly. The lambda function will retrieve all the instances that have a tag with a key StopGroup, and a value being the name of the lambda function you provided.

For instance, if you named your lambda function OfficeHoursTerminator, make sure you add a tag with key-value StopGroup=OfficeHoursTerminator to all the instances you want to stop at the provided schedule.

IAM Role

Make sure your lambda function is able to describe and stop instances.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "MyStatementId",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances",
                "ec2:StopInstances"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

Related

License

MIT © Sam Verschueren

aws-lambda-stop-server's People

Contributors

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