Skip to content

Commit

Permalink
Allow customisable cron expression for bastion scale up/down schedules (
Browse files Browse the repository at this point in the history
#276)

* Variable for scale cron expressions

* terraform-docs: automated action

* change to using one var with keys

* terraform-docs: automated action

* Update variables.tf

* terraform-docs: automated action

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
georgepstaylor and github-actions[bot] authored Oct 18, 2023
1 parent 3dc3689 commit 5d862d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ In order to prevent older versions from being retained forever, in addition to t
|------|-------------|------|---------|:--------:|
| <a name="input_allow_ssh_commands"></a> [allow\_ssh\_commands](#input\_allow\_ssh\_commands) | Allow SSH commands to be specified | `bool` | n/a | yes |
| <a name="input_app_name"></a> [app\_name](#input\_app\_name) | Name of application | `string` | n/a | yes |
| <a name="input_autoscaling_cron"></a> [autoscaling\_cron](#input\_autoscaling\_cron) | Cron expressions for scale up and scale down | `map(string)` | <pre>{<br> "down": "0 20 * * *",<br> "up": "0 5 * * *"<br>}</pre> | no |
| <a name="input_bucket_force_destroy"></a> [bucket\_force\_destroy](#input\_bucket\_force\_destroy) | The bucket and all objects should be destroyed when using true | `bool` | n/a | yes |
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Bucket used for bucket log storage and user public keys | `string` | n/a | yes |
| <a name="input_bucket_versioning"></a> [bucket\_versioning](#input\_bucket\_versioning) | Enable bucket versioning or not | `bool` | n/a | yes |
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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.autoscaling_cron["up"]
autoscaling_group_name = aws_autoscaling_group.bastion_linux_daily.name
}

Expand All @@ -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.autoscaling_cron["down"]
autoscaling_group_name = aws_autoscaling_group.bastion_linux_daily.name
}
8 changes: 8 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,11 @@ variable "tags_prefix" {
description = "prefix for name tags"
type = string
}
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
}
}

0 comments on commit 5d862d5

Please sign in to comment.