From 0e3b91255f15ced2369e8fd6099a9a1c2d7881aa Mon Sep 17 00:00:00 2001 From: George Taylor Date: Tue, 17 Oct 2023 22:07:11 +0100 Subject: [PATCH 1/6] Variable for scale cron expressions --- main.tf | 4 ++-- variables.tf | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 49cd649..3527c23 100644 --- a/main.tf +++ b/main.tf @@ -491,7 +491,7 @@ resource "aws_autoscaling_schedule" "bastion_linux_scale_down" { min_size = 0 max_size = 0 desired_capacity = 0 - recurrence = "0 20 * * *" # 20.00 UTC time or 21.00 London time + recurrence = var.scale_down_cron autoscaling_group_name = aws_autoscaling_group.bastion_linux_daily.name } @@ -500,6 +500,6 @@ resource "aws_autoscaling_schedule" "bastion_linux_scale_up" { min_size = 1 max_size = 1 desired_capacity = 1 - recurrence = "0 5 * * *" # 5.00 UTC time or 6.00 London time + recurrence = var.scale_up_cron autoscaling_group_name = aws_autoscaling_group.bastion_linux_daily.name } diff --git a/variables.tf b/variables.tf index 70d46c9..273da1e 100644 --- a/variables.tf +++ b/variables.tf @@ -112,3 +112,15 @@ variable "tags_prefix" { description = "prefix for name tags" type = string } + +variable "scale_down_cron" { + description = "Cron expression for scale down" + type = string + default = "0 20 * * *" # 20.00 UTC time or 21.00 London time +} + +variable "scale_up_cron" { + description = "Cron expression for scale up" + type = string + default = "0 5 * * *" # 5.00 UTC time or 6.00 London time +} From 0141769a4d6d475b14fa6779051d1c6baa05a552 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Oct 2023 21:08:20 +0000 Subject: [PATCH 2/6] terraform-docs: automated action --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bbc1482..3904c42 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,8 @@ In order to prevent older versions from being retained forever, in addition to t | [log\_standard\_ia\_days](#input\_log\_standard\_ia\_days) | Number of days before moving logs to IA Storage | `number` | n/a | yes | | [public\_key\_data](#input\_public\_key\_data) | User public keys for specific environment | `map(any)` | n/a | yes | | [region](#input\_region) | #Main | `string` | n/a | yes | +| [scale\_down\_cron](#input\_scale\_down\_cron) | Cron expression for scale down | `string` | `"0 20 * * *"` | no | +| [scale\_up\_cron](#input\_scale\_up\_cron) | Cron expression for scale up | `string` | `"0 5 * * *"` | no | | [subnet\_set](#input\_subnet\_set) | Fixed variable to specify subnet-set for RAM shared subnets | `string` | n/a | yes | | [tags\_common](#input\_tags\_common) | MOJ required tags | `map(string)` | n/a | yes | | [tags\_prefix](#input\_tags\_prefix) | prefix for name tags | `string` | n/a | yes | From bd89606b7ab0390d90f95bb7ae26048668eba9a2 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Wed, 18 Oct 2023 10:10:23 +0100 Subject: [PATCH 3/6] change to using one var with keys --- main.tf | 4 ++-- variables.tf | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.tf b/main.tf index 3527c23..ade0d18 100644 --- a/main.tf +++ b/main.tf @@ -491,7 +491,7 @@ resource "aws_autoscaling_schedule" "bastion_linux_scale_down" { min_size = 0 max_size = 0 desired_capacity = 0 - recurrence = var.scale_down_cron + recurrence = var.autoscaling_cron["up"] autoscaling_group_name = aws_autoscaling_group.bastion_linux_daily.name } @@ -500,6 +500,6 @@ resource "aws_autoscaling_schedule" "bastion_linux_scale_up" { min_size = 1 max_size = 1 desired_capacity = 1 - recurrence = var.scale_up_cron + recurrence = var.autoscaling_cron["down"] autoscaling_group_name = aws_autoscaling_group.bastion_linux_daily.name } diff --git a/variables.tf b/variables.tf index 273da1e..b820911 100644 --- a/variables.tf +++ b/variables.tf @@ -119,8 +119,11 @@ variable "scale_down_cron" { default = "0 20 * * *" # 20.00 UTC time or 21.00 London time } -variable "scale_up_cron" { - description = "Cron expression for scale up" - type = string - default = "0 5 * * *" # 5.00 UTC time or 6.00 London time +variable "autoscaling_cron" { + description = "Cron expressions for scale up and scale down" + type = map(string) + default = { + "up" = "0 5 * * *" # 5.00 UTC or 6.00 BST + "down" = "0 20 * * *" # 20.00 UTC or 21.00 BST + } } From b8ee09380500fa6598b7d99df5f6daa049a76a2d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 18 Oct 2023 09:10:56 +0000 Subject: [PATCH 4/6] terraform-docs: automated action --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3904c42..dc71371 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ In order to prevent older versions from being retained forever, in addition to t |------|-------------|------|---------|:--------:| | [allow\_ssh\_commands](#input\_allow\_ssh\_commands) | Allow SSH commands to be specified | `bool` | n/a | yes | | [app\_name](#input\_app\_name) | Name of application | `string` | n/a | yes | +| [autoscaling\_cron](#input\_autoscaling\_cron) | Cron expressions for scale up and scale down | `map(string)` |
{
"down": "0 20 * * *",
"up": "0 5 * * *"
}
| no | | [bucket\_force\_destroy](#input\_bucket\_force\_destroy) | The bucket and all objects should be destroyed when using true | `bool` | n/a | yes | | [bucket\_name](#input\_bucket\_name) | Bucket used for bucket log storage and user public keys | `string` | n/a | yes | | [bucket\_versioning](#input\_bucket\_versioning) | Enable bucket versioning or not | `bool` | n/a | yes | @@ -168,7 +169,6 @@ In order to prevent older versions from being retained forever, in addition to t | [public\_key\_data](#input\_public\_key\_data) | User public keys for specific environment | `map(any)` | n/a | yes | | [region](#input\_region) | #Main | `string` | n/a | yes | | [scale\_down\_cron](#input\_scale\_down\_cron) | Cron expression for scale down | `string` | `"0 20 * * *"` | no | -| [scale\_up\_cron](#input\_scale\_up\_cron) | Cron expression for scale up | `string` | `"0 5 * * *"` | no | | [subnet\_set](#input\_subnet\_set) | Fixed variable to specify subnet-set for RAM shared subnets | `string` | n/a | yes | | [tags\_common](#input\_tags\_common) | MOJ required tags | `map(string)` | n/a | yes | | [tags\_prefix](#input\_tags\_prefix) | prefix for name tags | `string` | n/a | yes | From a09e37a46ccea1b457947cd3d96c91ca406e6968 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Wed, 18 Oct 2023 10:45:41 +0100 Subject: [PATCH 5/6] Update variables.tf --- variables.tf | 7 ------- 1 file changed, 7 deletions(-) diff --git a/variables.tf b/variables.tf index b820911..01d098b 100644 --- a/variables.tf +++ b/variables.tf @@ -112,13 +112,6 @@ variable "tags_prefix" { description = "prefix for name tags" type = string } - -variable "scale_down_cron" { - description = "Cron expression for scale down" - type = string - default = "0 20 * * *" # 20.00 UTC time or 21.00 London time -} - variable "autoscaling_cron" { description = "Cron expressions for scale up and scale down" type = map(string) From fd73f54ed4321bf590462d7486391a0ec8259711 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 18 Oct 2023 09:46:44 +0000 Subject: [PATCH 6/6] terraform-docs: automated action --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index dc71371..a396965 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,6 @@ In order to prevent older versions from being retained forever, in addition to t | [log\_standard\_ia\_days](#input\_log\_standard\_ia\_days) | Number of days before moving logs to IA Storage | `number` | n/a | yes | | [public\_key\_data](#input\_public\_key\_data) | User public keys for specific environment | `map(any)` | n/a | yes | | [region](#input\_region) | #Main | `string` | n/a | yes | -| [scale\_down\_cron](#input\_scale\_down\_cron) | Cron expression for scale down | `string` | `"0 20 * * *"` | no | | [subnet\_set](#input\_subnet\_set) | Fixed variable to specify subnet-set for RAM shared subnets | `string` | n/a | yes | | [tags\_common](#input\_tags\_common) | MOJ required tags | `map(string)` | n/a | yes | | [tags\_prefix](#input\_tags\_prefix) | prefix for name tags | `string` | n/a | yes |