Skip to content

wcampos/terraform_aws_module_ec2_start_stop_scheduled_trigger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Module to Start and Stop EC2 Instances based on schedule

This module requires a tag:key and tag:value to query aws ec2 instances and apply the schedule to stop or start

Scheduled events are managed by a Cron, the format can be found: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html

How to use

Example:

module "stop_jenkins" {
  source = "git::https://github.com/wcampos/terraform_aws_module_ec2_start_stop_scheduled_trigger.git"

  region         = "us-east-1"
  prefix         = "test"
  tag_key        = "Name"
  tag_value      = "MyMachineName"
  instance_state = "Stop"
  cron_schedule  = "cron(0 12 * * ? *)"

}

Requirements

No requirements.

Providers

Name Version
archive n/a
aws n/a

Modules

No modules.

Resources

Name Type
aws_cloudwatch_event_rule.start_stop_lambda_cw_event_rule resource
aws_cloudwatch_event_target.start_stop_lambda resource
aws_iam_policy.start_stop_lambda resource
aws_iam_role.start_stop_lambda resource
aws_iam_role_policy_attachment.start_stop_lambda_policy_attachment resource
aws_lambda_function.start_stop_lambda resource
aws_lambda_permission.start_stop_lambda resource
archive_file.start_stop_lambda data source

Inputs

Name Description Type Default Required
cron_schedule Cron Expression to Start or Stop EC2s string "" no
instance_state Desire state for Ec2s. Available options: [ 'Start', 'Stop'] string "" no
region EC2 Instances Region string "" no
tag_key Name of the Tag:Key used on ec2 filter string "" no
tag_value Value for the Tag:Value used for ec2 filter string "" no

Outputs

No outputs.

About

Terraform Module to Start or Stop EC2s on a schedule

Resources

Stars

Watchers

Forks

Packages