Skip to content

Latest commit

 

History

History
52 lines (43 loc) · 1.45 KB

README.md

File metadata and controls

52 lines (43 loc) · 1.45 KB

AWS EC2 Scheduler to STOP and START EC2 Instances

This Terraform deploy:

  • Lambda Function to Stop EC2 Instances with specific Tag
  • Lambda Function to Start EC2 Instances with specific Tag
  • EventBridge Rule to Stop EC2 Instances by CRON schedule
  • EventBridge Rule to Start EC2 Instances by CRON schedule
  • CloudWatch Log Group for Lambda Stop EC2
  • CloudWatch Log Group for Lambda Start EC2
  • IAM Role with IAM Policy to Describe/Stop/Start EC2


Note

Cron schedules are in UTC time Zone!

Cron Expression examples:

Examples:

start_cron_schedule = "cron(00 07 * * ? *)"  # Start Servers at 07:00 UTC
stop_cron_schedule  = "cron(00 17 * * ? *)"  # Stop  Servers at 17:00 UTC

How to use with all Default:

module "ec2_scheduler_default" {
  source = "github.com/adv4000/aws-ec2-scheduler.git"
}

How to use with all Custom:

module "ec2_scheduler_custom" {
  source              = "github.com/adv4000/aws-ec2-scheduler.git"
  name                = "my-ec2-scheduler"
  stop_cron_schedule  = "cron(00 16 * * ? *)"
  start_cron_schedule = "cron(00 08 * * ? *)"

  stopstart_tags = {
    TagKEY   = "stopstart_me"
    TagVALUE = "yes"
  }

  tags = {
    Owner = "Denis Astahov"
  }
}

Copyleft (c) by Denis Astahov ADV-IT