Skip to content

deividduarte20/lambda_stop_start_ec2_tf

Repository files navigation

Esse projeto consiste em provisionar agendamento de stop/start de instâncias EC2

Para inserir instâncias no desligamento por horário basta inserir tag na instância desejada

key: schedule
value: true

Em variable expr no arquivo de variables.tf ajuste o horário necessário lembrando que são 3 horas a frente, exemplo se você deseja efetuar o stop no horário de 18:00 insira 21:00.

Baixe o projeto

git clone https://github.com/deividduarte20/lambda_stop_start_ec2_tf.git

Inicie o terraform

terraform init

Aplique a infra como código

terraform apply

Requirements

Name Version
terraform >= 1.0.3
aws >= 3.74.3

Providers

Name Version
archive 2.2.0
aws 4.48.0

Resources

Name Type
aws_cloudwatch_event_rule.profile_startec2_lambda_event_rule resource
aws_cloudwatch_event_rule.profile_stopec2_lambda_event_rule resource
aws_cloudwatch_event_target.profile_gstopec2_lambda_target resource
aws_cloudwatch_event_target.profile_startec2_lambda_target resource
aws_iam_role.cloudprotegida-ec2-lambda-role-stopstart resource
aws_iam_role_policy.cloudprotegida-ec2-lambda-policy-stopstart resource
aws_lambda_function.lambda_startec2 resource
aws_lambda_function.lambda_stopec2 resource
aws_lambda_permission.allow_cloudwatch_startec2_lambda resource
aws_lambda_permission.allow_cloudwatch_to_call_stopec2_lambda resource
archive_file.lambda_startec2 data source
archive_file.lambda_stopec2 data source

Inputs

Name Description Type Default Required
lambda_env n/a map
{
"KEY": "schedule",
"VALUE": "true"
}
no
lambda_timeout n/a number 600 no
profile n/a string "default" no
project n/a string "lambda-manager-ec2" no
sched_expr n/a map
{
"start": "cron(0 10 ? * * *)",
"stop": "cron(00 21 ? * * *)"
}
no
tags n/a map
{
"Name": "lambda-manager-ec2",
"Product": "lambda",
"Team": "sre"
}
no

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published