The script schedules the start/stop of EC2 instances based on tag, whether they are standalone instances or instances within an autoscaling group.
This assumes you have set the "nightly" tag on the EC2/Autoscaling group to 'onoff' or to keep it off unless needed. The lambda affects only instances in the same region than your terraform.
Remember this uses UTC Time
Requires the following tag:
extra_tags = [
{
key = "nightly"
value = "onoff"
propagate_at_launch = true
},
]
module "aws_scheduler" {
source = ""
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
aws_region | string | "eu-west-1" |
no | |
ec2_start_cron | Rate expression for when to run the start ec2 lambda | string | "cron(0 7 ? * MON-FRI *)" |
no |
ec2_stop_cron | Rate expression for when to run the stop ec2 lambda | string | "cron(0 21 ? * MON-FRI *)" |
no |
enabled | Enable that module or not | string | "1" |
no |
function_prefix | Prefix for the name of the lambda created | string | "" |
no |
Configure your AWS credentials using one of the supported methods for AWS CLI
tools, such as setting the
AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables. If you're using the ~/.aws/config
file for profiles then export AWS_SDK_LOAD_CONFIG
as "True".