Skip to content

Instantly share code, notes, and snippets.

@vronin
Last active February 8, 2023 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vronin/9303e264854d556a548d90496b605a0d to your computer and use it in GitHub Desktop.
Save vronin/9303e264854d556a548d90496b605a0d to your computer and use it in GitHub Desktop.
resource "aws_scheduler_schedule" "my_scheduler" {
name = "my-scheduler"
group_name = "default"
flexible_time_window {
mode = "OFF"
}
# Run it each Monday
schedule_expression = "cron(0 9 ? * MON *)"
target {
# This indicates that the event should be send to EC2 API and startInstances action should be triggered
arn = "arn:aws:scheduler:::aws-sdk:ec2:startInstances"
role_arn = aws_iam_role.my_role.arn
# And this block will be passed to startInstances API
input = jsonencode({
InstanceIds = [
aws_instance.my_ec2.id
]
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment