Skip to content

Terraform module for starting and stopping an RDS instance/cluster on a schedule

License

Notifications You must be signed in to change notification settings

pedwin-scottlogic/terraform-aws-rds-scheduler

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  ____  ____  ____    ____       _              _       _
 |  _ \|  _ \/ ___|  / ___|  ___| |__   ___  __| |_   _| | ___ _ __
 | |_) | | | \___ \  \___ \ / __| '_ \ / _ \/ _` | | | | |/ _ \ '__|
 |  _ <| |_| |___) |  ___) | (__| | | |  __/ (_| | |_| | |  __/ |
 |_| \_\____/|____/  |____/ \___|_| |_|\___|\__,_|\__,_|_|\___|_|

Introduction

This is a Terraform module that allows you to set up a scheduled start/stop time for your RDS instances and clusters. Depending on your schedule and the size of your RDS resources, this could save you some serious money.

You'd generally want to use this in dev/staging environments where the RDS isn't always in use.

Versions

Use version ~> 1.1.0 for Terraform versions <= 0.11.x Use version ~> 2.0.0 for Terraform versions >= 0.12.x

Usage

For Terraform versions <= 0.11.x

module "rds_schedule" {
  source  = "github.com/barryw/terraform-aws-rds-scheduler"
  version = "~> 1.1.0"

  /* Don't stop RDS in production! */
  skip_execution = "${var.environment == "prod"}"
  identifier     = "${var.product_name}-${var.environment}"

  /* Start the RDS cluster at 6:50am EDT Monday - Friday */
  up_schedule    = "cron(50 10 ? * MON-FRI *)"
  /* Stop the RDS cluster at 9pm EDT every night */
  down_schedule  = "cron(0 1 * * ? *)"

  rds_identifier = "${data.aws_rds_cluster.rds.cluster_identifier}"
  is_cluster     = true
}

For Terraform versions >= 0.12.x

module "rds_schedule" {
  source  = "github.com/barryw/terraform-aws-rds-scheduler"
  version = "~> 2.0.0"

  /* Don't stop RDS in production! */
  skip_execution = var.environment == "prod"
  identifier     = "${var.product_name}-${var.environment}"

  /* Start the RDS cluster at 6:50am EDT Monday - Friday */
  up_schedule    = "cron(50 10 ? * MON-FRI *)"
  /* Stop the RDS cluster at 9pm EDT every night */
  down_schedule  = "cron(0 1 * * ? *)"

  rds_identifier = data.aws_rds_cluster.rds.cluster_identifier
  is_cluster     = true
}

This example would stop RDS every night at 9pm EDT and start it every weekday morning at 6:50am EDT.

If you'd like to disable this module for certain cases, you can pass in an expression that evaluates to true for skip_execution

NOTE The cron schedules are specified in UTC.

License

This module is licensed under the MIT license: https://opensource.org/licenses/MIT

About

Terraform module for starting and stopping an RDS instance/cluster on a schedule

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 67.0%
  • Python 33.0%