Giter VIP home page Giter VIP logo

aws-ec2-lambdas's Introduction

AWS lambda functions for EC2

Python 2.7 | 3.6 Build Status

My AWS Lambda functions for personal use.

Scripts being run through Lambda

  1. EC2/autostop_ec2/autostop-ec2

    • Autostop EC2 instances with specified tag
  2. EC2/autostop_ec2/reset-autostop-ec2

    • Reset Autostop tags of specific EC2 instances
  3. EC2/backup_ec2/create-ec2-backups

    • Create AMI and Snapshot(s) for EC2 instance
    • Managed by role: Lambda-EC2-Snapper
  4. EC2/backup_ec2/tag-ec2-backups

    • Tag Snapshots of AMI of EC2 instance
    • Managed by role: Lambda-EC2-Snapper
  5. EC2/backup_ec2/delete-ec2-backups

    • Delete expired backup (AMI and the corresponding Snapshots)
    • Managed by role: Lambda-EC2-Snapper

How the scripts are used

These scripts are intended to be run as AWS Lambda jobs triggered by an AWS CloudWatch scheduled event. They can also be run from command line or from crontab.

Run from AWS Lambda

Lambda is a code execution service offered by Amazon Web Services. When you configure a single Lambda behavior, it runs based on events you specify without needing a server of any kind.

  1. Create an AWS IAM Role that allows the AWS Lambda service to call AWS services (e.g. Lambda-EC2-Snapper).

  2. Create a new AWS Lambda function with the contents of create-ec2-backups.py. Configure the DEFAULTS as appropriate for your environment.

  3. Add a new CloudWatch Schedule Trigger for the Lambda function at the interval you require.

  4. Wait for CloudWatch to trigger the scheduled event or use the AWS Lambda "Test" button to run manually.

Run from Command Line

  1. Set up AWS configure to store your Access Key ID and Secret Access Key in ~/.aws. See "Configuring the AWS Command Line Interface" for more details.

  2. Change profile_name and DEFAULTS in the main of the scripts

  3. Build

virtualenv env
. env/bin/activate    (on linux; or env\Scripts\activate on Windows)
pip install -r requirements.txt

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.