diff --git a/README.md b/README.md index 499d62fa..639270c3 100644 --- a/README.md +++ b/README.md @@ -70,12 +70,12 @@ module "start_ec2_instance" { | kms_key_arn | The ARN for the KMS encryption key. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key | string | null | no | | aws_regions | A list of one or more aws regions where the lambda will be apply, default use the current region | list | null | no | | cloudwatch_schedule_expression | The scheduling expression | string | `"cron(0 22 ? * MON-FRI *)"` | yes | +| schedule_action | Define schedule action to apply on resources | string | `"stop"` | yes | +| resources_tag | Set the tag use for identify resources to stop or start | map | { tostop = "true" } | yes | | autoscaling_schedule | Enable scheduling on autoscaling resources | string | `"false"` | no | | ec2_schedule | Enable scheduling on ec2 instance resources | string | `"false"` | no | | rds_schedule | Enable scheduling on rds resources | string | `"false"` | no | | cloudwatch_alarm_schedule | Enable scheduleding on cloudwatch alarm resources | string | `"false"` | no | -| schedule_action | Define schedule action to apply on resources | string | `"stop"` | yes | -| scheduler_tag | Set the tag to use for identify aws resources to stop or start | map | {"key" = "tostop", "value" = "true"} | yes | ## Outputs diff --git a/examples/autoscaling-scheduler/main.tf b/examples/autoscaling-scheduler/main.tf index ea8ccd3c..da9b6e94 100644 --- a/examples/autoscaling-scheduler/main.tf +++ b/examples/autoscaling-scheduler/main.tf @@ -98,7 +98,7 @@ module "autoscaling-stop-friday" { autoscaling_schedule = "true" cloudwatch_alarm_schedule = "true" - scheduler_tag = { + resources_tag = { key = "tostop" value = "true" } @@ -114,7 +114,7 @@ module "autoscaling-start-monday" { autoscaling_schedule = "true" cloudwatch_alarm_schedule = "true" - scheduler_tag = { + resources_tag = { key = "tostop" value = "true" } diff --git a/examples/instance-scheduler/main.tf b/examples/instance-scheduler/main.tf index 78767cb1..3d65b3d5 100644 --- a/examples/instance-scheduler/main.tf +++ b/examples/instance-scheduler/main.tf @@ -47,7 +47,7 @@ module "ec2-stop-friday" { autoscaling_schedule = "false" cloudwatch_alarm_schedule = "true" - scheduler_tag = { + resources_tag = { key = "tostop" value = "true" } @@ -63,7 +63,7 @@ module "ec2-start-monday" { autoscaling_schedule = "false" cloudwatch_alarm_schedule = "true" - scheduler_tag = { + resources_tag = { key = "tostop" value = "true" } diff --git a/examples/rds-scheduler/main.tf b/examples/rds-scheduler/main.tf index 76aadb9d..bf237afd 100644 --- a/examples/rds-scheduler/main.tf +++ b/examples/rds-scheduler/main.tf @@ -104,7 +104,7 @@ module "rds-stop-friday" { autoscaling_schedule = "false" cloudwatch_alarm_schedule = "true" - scheduler_tag = { + resources_tag = { key = "tostop" value = "true" } @@ -120,7 +120,7 @@ module "rds-start-monday" { autoscaling_schedule = "false" cloudwatch_alarm_schedule = "true" - scheduler_tag = { + resources_tag = { key = "tostop" value = "true" } diff --git a/examples/test_fixture/main.tf b/examples/test_fixture/main.tf index 9a0483bf..ea7a4a4f 100644 --- a/examples/test_fixture/main.tf +++ b/examples/test_fixture/main.tf @@ -15,7 +15,7 @@ module "aws-stop-friday" { ec2_schedule = "true" rds_schedule = "true" - scheduler_tag = { + resources_tag = { key = "tostop" value = "true" } @@ -30,7 +30,7 @@ module "aws-start-monday" { ec2_schedule = "true" rds_schedule = "true" - scheduler_tag = { + resources_tag = { key = "tostop" value = "true" } diff --git a/main.tf b/main.tf index e3065132..4641e2ef 100644 --- a/main.tf +++ b/main.tf @@ -210,8 +210,6 @@ locals { } ] } - # Backwared compatibility with the former terraform variable name. - scheduler_tag = var.scheduler_tag == { "key" = "tostop", "value" = "true" } ? var.resources_tag : var.scheduler_tag } ################################################ @@ -224,7 +222,7 @@ locals { data "archive_file" "this" { type = "zip" source_dir = "${path.module}/package/" - output_path = "${path.module}/aws-stop-start-resources-3.1.1.zip" # The version should match with the latest git tag + output_path = "${path.module}/aws-stop-start-resources-3.1.2.zip" # The version should match with the latest git tag } # Create Lambda function for stop or start aws resources @@ -241,8 +239,8 @@ resource "aws_lambda_function" "this" { variables = { AWS_REGIONS = var.aws_regions == null ? data.aws_region.current.name : join(", ", var.aws_regions) SCHEDULE_ACTION = var.schedule_action - TAG_KEY = local.scheduler_tag["key"] - TAG_VALUE = local.scheduler_tag["value"] + TAG_KEY = var.resources_tag["key"] + TAG_VALUE = var.resources_tag["value"] EC2_SCHEDULE = tostring(var.ec2_schedule) RDS_SCHEDULE = tostring(var.rds_schedule) AUTOSCALING_SCHEDULE = tostring(var.autoscaling_schedule) diff --git a/variables.tf b/variables.tf index acb1d23f..02844d1a 100644 --- a/variables.tf +++ b/variables.tf @@ -39,23 +39,12 @@ variable "schedule_action" { } variable "resources_tag" { - # This variable has been renamed to "scheduler_tag" - description = "DEPRECATED, use scheduler_tag variable instead" + description = "Set the tag use for identify resources to stop or start" type = map(string) default = { - "key" = "tostop" - "value" = "true" - } -} - -variable "scheduler_tag" { - description = "Set the tag to use for identify aws resources to stop or start" - type = map(string) - - default = { - "key" = "tostop" - "value" = "true" + key = "tostop" + value = "true" } }