Coder Social home page Coder Social logo

ebs_snapshot_terraform's Introduction

Terraform config for automatic EBS snapshots

This repo contains a terraform configuration that creates two lambda functions that will take automatic EBS snapshots at regular intervals. It is based on the code at https://serverlesscode.com/post/lambda-schedule-ebs-snapshot-backups/ and https://serverlesscode.com/post/lambda-schedule-ebs-snapshot-backups-2/.

Usage

Terraform Module

This is intended for use as a module in another project. You would include it like so:

// ... other resources

module "ebs_backups" {
  source = "github.com:nathanielks/ebs_snapshot_terraform"
}

It exposes the following variables:

  • backups_schedule: a rate or cron expression. Defaults to cron(0 20 * * ? *). See Schedule Expressions for more info.
  • janitor_schedule: a rate or cron expression. Defaults to cron(30 20 * * ? *). See Schedule Expressions for more info.
  • backups_zip: the filepath to the file to use as the scheduled backup Lambda function. Lambda functions uploaded via terraform need to be uploaded as a zip file.
  • janitor_zip: the filepath to the file to use as the janitor Lambda function. Lambda functions uploaded via terraform need to be uploaded as a zip file.

If you wanted to run a backup every hour:

module "ebs_backups" {
  source = "github.com:nathanielks/ebs_snapshot_terraform"

  backups_schedule = "rate(1 hour)"
}

If you wanted to use your own backup script:

module "ebs_backups" {
  source = "github.com:nathanielks/ebs_snapshot_terraform"

  backups_zip = "${path.module}/backup.zip"
}

Configuring your instances to be backed up

Tag any instances you want to be backed up with Backup = true.

By default, old backups will be removed after 7 days, to keep them longer, set another tag: Retention = 14, where 14 is the number of days you want to keep the backups for.

Contributing

Updating the script

Lambda functions uploaded via terraform need to be uploaded as a zip file. To change the code, make your changes to the python code and then run make. This will create/update the zip files for terraform to re-upload.

ebs_snapshot_terraform's People

Contributors

mivok avatar nathanielks 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.