Skip to content

ibliskavka/scheduled-ec2-reboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scheduled EC2 Reboot

This is a tiny lambda which can reboot EC2 instances on a cron schedule.

Use this project as an example to create other scheduled maintenance scripts in your AWS environment.

Permissions Warning

For simplicity, this lambda gets ec2:RebootInstances permissions automatically. If your environment requires more granular permissions, please add each instance ARN to template.yaml line 37

Installation

Prerequisites

Deploy Script

See deploy.sh for instructions on how to deploy

Parameters

  • PROFILE: Which AWS Profile to use during the deploy
  • REGION: Which AWS Region to deploy to
  • BUCKET: Artifact bucket used by SAM - this should be created beforehand
  • STACK_NAME: The name of your CloudFormation stack
  • SCHEDULE: CRON expression
  • EC2_ID_CSV: Comma separated list of EC2 instance IDs

Troubleshooting

Deployment errors will be visible in your AWS CloudFormation console. Look for your stack name, and see the events tab.

Lambda execution errors can be found in the AWS Lambda console. Search for the lambda function who's name starts with {StackName}-ScheduledReboot-{...} and check the Monitoring tab for execution history and error rates.

Additional Information: RebootInstances Service Reference

Removal

To remove the lambda, simply delete the CloudFormation stack.

About

A tiny AWS SAM Lambda that can trigger EC2 reboots on a Cron schedule.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published