Skip to content

Commit

Permalink
Merge pull request #1 from Comocomo/scaling-cooldown-variables
Browse files Browse the repository at this point in the history
Added scaling cooldown variables.
  • Loading branch information
Jon-Berg authored Jun 27, 2023
2 parents bf322c2 + 1b706de commit 20611cb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ module "dynamodb_autoscaler" {
autoscale_max_read_capacity = 20
autoscale_min_write_capacity = 5
autoscale_max_write_capacity = 20
autoscale_scale_in_cooldown = null # defaults to AWS's default
autoscale_scale_out_cooldown = null # defaults to AWS's default
}
```

Expand Down Expand Up @@ -182,6 +184,8 @@ Available targets:
| <a name="input_autoscale_min_write_capacity_index"></a> [autoscale\_min\_write\_capacity\_index](#input\_autoscale\_min\_write\_capacity\_index) | DynamoDB autoscaling min write capacity of the index | `number` | `null` | no |
| <a name="input_autoscale_read_target"></a> [autoscale\_read\_target](#input\_autoscale\_read\_target) | The target value for DynamoDB read autoscaling | `number` | `50` | no |
| <a name="input_autoscale_read_target_index"></a> [autoscale\_read\_target\_index](#input\_autoscale\_read\_target\_index) | The target value for DynamoDB read autoscaling of the index | `number` | `null` | no |
| <a name="input_autoscale_scale_in_cooldown"></a> [autoscale\_scale\_in\_cooldown](#input\_autoscale\_scale\_in\_cooldown) | DynamoDB autoscaling scale in cooldown | `number` | `null` | no |
| <a name="input_autoscale_scale_out_cooldown"></a> [autoscale\_scale\_out\_cooldown](#input\_autoscale\_scale\_out\_cooldown) | DynamoDB autoscaling scale out cooldown | `number` | `null` | no |
| <a name="input_autoscale_write_target"></a> [autoscale\_write\_target](#input\_autoscale\_write\_target) | The target value for DynamoDB write autoscaling | `number` | `50` | no |
| <a name="input_autoscale_write_target_index"></a> [autoscale\_write\_target\_index](#input\_autoscale\_write\_target\_index) | The target value for DynamoDB write autoscaling of the index | `number` | `null` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
Expand Down
2 changes: 2 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ usage: |-
autoscale_max_read_capacity = 20
autoscale_min_write_capacity = 5
autoscale_max_write_capacity = 20
autoscale_scale_in_cooldown = null # defaults to AWS's default
autoscale_scale_out_cooldown = null # defaults to AWS's default
}
```
include:
Expand Down
2 changes: 2 additions & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
| <a name="input_autoscale_min_write_capacity_index"></a> [autoscale\_min\_write\_capacity\_index](#input\_autoscale\_min\_write\_capacity\_index) | DynamoDB autoscaling min write capacity of the index | `number` | `null` | no |
| <a name="input_autoscale_read_target"></a> [autoscale\_read\_target](#input\_autoscale\_read\_target) | The target value for DynamoDB read autoscaling | `number` | `50` | no |
| <a name="input_autoscale_read_target_index"></a> [autoscale\_read\_target\_index](#input\_autoscale\_read\_target\_index) | The target value for DynamoDB read autoscaling of the index | `number` | `null` | no |
| <a name="input_autoscale_scale_in_cooldown"></a> [autoscale\_scale\_in\_cooldown](#input\_autoscale\_scale\_in\_cooldown) | DynamoDB autoscaling scale in cooldown | `number` | `null` | no |
| <a name="input_autoscale_scale_out_cooldown"></a> [autoscale\_scale\_out\_cooldown](#input\_autoscale\_scale\_out\_cooldown) | DynamoDB autoscaling scale out cooldown | `number` | `null` | no |
| <a name="input_autoscale_write_target"></a> [autoscale\_write\_target](#input\_autoscale\_write\_target) | The target value for DynamoDB write autoscaling | `number` | `50` | no |
| <a name="input_autoscale_write_target_index"></a> [autoscale\_write\_target\_index](#input\_autoscale\_write\_target\_index) | The target value for DynamoDB write autoscaling of the index | `number` | `null` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
Expand Down
12 changes: 10 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ resource "aws_appautoscaling_policy" "read_policy" {
predefined_metric_type = "DynamoDBReadCapacityUtilization"
}

target_value = var.autoscale_read_target
target_value = var.autoscale_read_target
scale_in_cooldown = var.autoscale_scale_in_cooldown
scale_out_cooldown = var.autoscale_scale_out_cooldown
}
}

Expand All @@ -49,7 +51,9 @@ resource "aws_appautoscaling_policy" "read_policy_index" {
predefined_metric_type = "DynamoDBReadCapacityUtilization"
}

target_value = coalesce(var.autoscale_read_target_index, var.autoscale_read_target)
target_value = coalesce(var.autoscale_read_target_index, var.autoscale_read_target)
scale_in_cooldown = var.autoscale_scale_in_cooldown
scale_out_cooldown = var.autoscale_scale_out_cooldown
}
}

Expand Down Expand Up @@ -86,6 +90,8 @@ resource "aws_appautoscaling_policy" "write_policy" {
}

target_value = var.autoscale_write_target
scale_in_cooldown = var.autoscale_scale_in_cooldown
scale_out_cooldown = var.autoscale_scale_out_cooldown
}
}

Expand All @@ -105,5 +111,7 @@ resource "aws_appautoscaling_policy" "write_policy_index" {
}

target_value = coalesce(var.autoscale_write_target_index, var.autoscale_write_target)
scale_in_cooldown = var.autoscale_scale_in_cooldown
scale_out_cooldown = var.autoscale_scale_out_cooldown
}
}
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ variable "autoscale_read_target" {
description = "The target value for DynamoDB read autoscaling"
}

variable "autoscale_scale_in_cooldown" {
type = number
default = null
description = "DynamoDB autoscaling scale in cooldown"
}

variable "autoscale_scale_out_cooldown" {
type = number
default = null
description = "DynamoDB autoscaling scale out cooldown"
}

variable "autoscale_min_read_capacity" {
type = number
default = 5
Expand Down

0 comments on commit 20611cb

Please sign in to comment.