A Terraform module for enabling auto-scaling for a target DynamoDB table.
Note: It's important you ignore changes to "READ" and "WRITE" units on your source DynamoDB table resource to prevent Terraform removing the scaling actions.
To enable auto-scaling on a table simply create the table resource and apply the auto-scaling module to the output table - ensuring that you ignore write & read capacity settings!
resource "aws_dynamodb_table" "snowplow_kcl_table" {
name = "my-table-name"
hash_key = "leaseKey"
write_capacity = 1
read_capacity = 1
attribute {
name = "leaseKey"
type = "S"
}
lifecycle {
ignore_changes = [write_capacity, read_capacity]
}
}
module "table_autoscaling" {
source = "snowplow-devops/dynamodb-autoscaling/aws"
table_name = aws_dynamodb_table.snowplow_kcl_table.id
}
Name | Version |
---|---|
terraform | >= 0.15 |
aws | >= 3.25.0 |
Name | Version |
---|---|
aws | >= 3.25.0 |
No modules.
Name | Type |
---|---|
aws_appautoscaling_policy.read_policy | resource |
aws_appautoscaling_policy.write_policy | resource |
aws_appautoscaling_target.read_target | resource |
aws_appautoscaling_target.write_target | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
read_max_capacity | The maximum READ capacity for the table | number |
50 |
no |
read_min_capacity | The minimum READ capacity for the table | number |
1 |
no |
read_scale_in_cooldown | The number of seconds before scaling IN can occur after a scaling action | number |
300 |
no |
read_scale_out_cooldown | The number of seconds before scaling OUT can occur after a scaling action | number |
30 |
no |
read_target_value | The target utilization percentage for the table | number |
85 |
no |
table_name | The name of the DynamoDB table to add auto-scaling to | string |
n/a | yes |
write_max_capacity | The maximum WRITE capacity for the table | number |
50 |
no |
write_min_capacity | The minimum WRITE capacity for the table | number |
1 |
no |
write_scale_in_cooldown | The number of seconds before scaling IN can occur after a scaling action | number |
300 |
no |
write_scale_out_cooldown | The number of seconds before scaling OUT can occur after a scaling action | number |
30 |
no |
write_target_value | The target utilization percentage for the table | number |
85 |
no |
Name | Description |
---|---|
read_policy_arn | ARN of the read policy |
write_policy_arn | ARN of the write policy |
The Terraform AWS DynamoDB AutoScaling project is Copyright 2021-2021 Snowplow Analytics Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.