Skip to content

Latest commit

 

History

History

schedule_shutdown

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Schedule shutdown

Lambda function to schedule resource shutdown and startup to save costs. The function is triggered by CloudWatch Events controlled by schedule expressions.

Currently the function supports scaling the following resources:

  • CloudWatch alarms: enables/disables the alarm actions.
  • ECS services: scales the service between 0 and 1 tasks.
  • RDS clusters: stops/starts the cluster.
  • Route53 healthchecks: enables/disables the healthcheck.

Requirements

No requirements.

Providers

Name Version
archive n/a
aws n/a

Modules

No modules.

Resources

Name Type
aws_cloudwatch_event_rule.schedule resource
aws_cloudwatch_event_target.schedule resource
aws_cloudwatch_log_group.schedule resource
aws_iam_policy.schedule resource
aws_iam_role.schedule resource
aws_iam_role_policy_attachment.schedule resource
aws_lambda_function.schedule resource
aws_lambda_permission.schedule resource
archive_file.schedule data source
aws_iam_policy_document.assume_role_policy data source
aws_iam_policy_document.cloudwatch_alarm_policy data source
aws_iam_policy_document.cloudwatch_policy data source
aws_iam_policy_document.combined data source
aws_iam_policy_document.ecs_service_policy data source
aws_iam_policy_document.rds_cluster_policy data source
aws_iam_policy_document.route53_healthcheck_policy data source

Inputs

Name Description Type Default Required
billing_tag_key (Optional, default 'CostCentre') The name of the billing tag string "CostCentre" no
billing_tag_value (Required) The value of the billing tag string n/a yes
cloudwatch_alarm_arns (Optional) CloudWatch alarm ARNs to enable/disable. list(string) [] no
ecs_service_arns (Optional) ECS service ARNs to scale up/down. list(string) [] no
lambda_runtime (Optional, defaults to 3.11) The Python runtime to use for the lambda function. string "python3.11" no
rds_cluster_arns (Optional) RDS cluster ARNs to shutdown and startup. list(string) [] no
route53_healthcheck_arns (Optional) Route53 healthcheck ARNs to enable/disable. list(string) [] no
schedule_shutdown (Optional, every day at 10pm UTC) The schedule expression for when resources should be stopped. string "cron(0 22 * * ? *)" no
schedule_startup (Optional, Monday-Friday at 10am UTC) The schedule expression for when resources should be started. string "cron(0 10 ? * MON-FRI *)" no

Outputs

No outputs.