diff --git a/README.md b/README.md index 639270c3..499d62fa 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 da9b6e94..ea8ccd3c 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" - resources_tag = { + scheduler_tag = { key = "tostop" value = "true" } @@ -114,7 +114,7 @@ module "autoscaling-start-monday" { autoscaling_schedule = "true" cloudwatch_alarm_schedule = "true" - resources_tag = { + scheduler_tag = { key = "tostop" value = "true" } diff --git a/examples/instance-scheduler/main.tf b/examples/instance-scheduler/main.tf index 3d65b3d5..78767cb1 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" - resources_tag = { + scheduler_tag = { key = "tostop" value = "true" } @@ -63,7 +63,7 @@ module "ec2-start-monday" { autoscaling_schedule = "false" cloudwatch_alarm_schedule = "true" - resources_tag = { + scheduler_tag = { key = "tostop" value = "true" } diff --git a/examples/rds-scheduler/main.tf b/examples/rds-scheduler/main.tf index bf237afd..76aadb9d 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" - resources_tag = { + scheduler_tag = { key = "tostop" value = "true" } @@ -120,7 +120,7 @@ module "rds-start-monday" { autoscaling_schedule = "false" cloudwatch_alarm_schedule = "true" - resources_tag = { + scheduler_tag = { key = "tostop" value = "true" } diff --git a/examples/test_fixture/main.tf b/examples/test_fixture/main.tf index ea7a4a4f..9a0483bf 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" - resources_tag = { + scheduler_tag = { key = "tostop" value = "true" } @@ -30,7 +30,7 @@ module "aws-start-monday" { ec2_schedule = "true" rds_schedule = "true" - resources_tag = { + scheduler_tag = { key = "tostop" value = "true" } diff --git a/main.tf b/main.tf index 4641e2ef..2a1ee7a1 100644 --- a/main.tf +++ b/main.tf @@ -210,6 +210,8 @@ locals { } ] } + # Backward compatibility with the former scheduler variable name. + scheduler_tag = var.resources_tag == null ? var.scheduler_tag : var.resources_tag } ################################################ @@ -222,7 +224,7 @@ locals { data "archive_file" "this" { type = "zip" source_dir = "${path.module}/package/" - output_path = "${path.module}/aws-stop-start-resources-3.1.2.zip" # The version should match with the latest git tag + output_path = "${path.module}/aws-stop-start-resources-3.1.3.zip" # The version should match with the latest git tag } # Create Lambda function for stop or start aws resources @@ -239,8 +241,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 = var.resources_tag["key"] - TAG_VALUE = var.resources_tag["value"] + TAG_KEY = local.scheduler_tag["key"] + TAG_VALUE = local.scheduler_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 02844d1a..f3e23102 100644 --- a/variables.tf +++ b/variables.tf @@ -39,12 +39,19 @@ variable "schedule_action" { } variable "resources_tag" { - description = "Set the tag use for identify resources to stop or start" + # This variable has been renamed to "scheduler_tag" + description = "DEPRECATED, use scheduler_tag variable instead" + type = map(string) + default = null +} + +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" } }