-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add schedule scaling possibility
- Loading branch information
1 parent
03b38ee
commit f801d6a
Showing
9 changed files
with
223 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
resource "aws_appautoscaling_scheduled_action" "index_schedule" { | ||
for_each = { for k, v in var.schedule_scaling_indexes : k => v } | ||
|
||
name = "${var.name}-${each.key}" | ||
|
||
resource_id = var.resource_id | ||
scalable_dimension = var.scalable_dimension | ||
service_namespace = var.service_namespace | ||
|
||
schedule = each.value["schedule"] | ||
|
||
scalable_target_action { | ||
max_capacity = each.value["max_capacity"] | ||
min_capacity = each.value["min_capacity"] | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
variable "schedule_scaling_indexes" { | ||
description = "A map of index schedule scaling configurations" | ||
type = list(object({ | ||
schedule = string | ||
min_capacity = number | ||
max_capacity = number | ||
})) | ||
} | ||
|
||
variable "service_namespace" { | ||
type = string | ||
description = "Namespace of the AWS service" | ||
} | ||
|
||
variable "resource_id" { | ||
type = string | ||
description = "Identifier of the resource associated with the scheduled action" | ||
} | ||
|
||
variable "scalable_dimension" { | ||
type = string | ||
description = "Scalable dimension" | ||
} | ||
|
||
variable "name" { | ||
description = "Name of the autoscaling action" | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 4.59" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
resource "aws_appautoscaling_scheduled_action" "table_read_schedule" { | ||
for_each = var.create_table && var.autoscaling_enabled && length(var.schedule_scaling_read) > 0 ? { for k, v in var.schedule_scaling_read : k => v } : {} | ||
|
||
name = "DynamoDBReadCapacityUtilization:${aws_appautoscaling_target.table_read[0].resource_id}" | ||
|
||
resource_id = aws_appautoscaling_target.table_read[0].resource_id | ||
scalable_dimension = aws_appautoscaling_target.table_read[0].scalable_dimension | ||
service_namespace = aws_appautoscaling_target.table_read[0].service_namespace | ||
|
||
schedule = each.value["schedule"] | ||
|
||
scalable_target_action { | ||
max_capacity = each.value["max_capacity"] | ||
min_capacity = each.value["min_capacity"] | ||
} | ||
} | ||
|
||
module "index_read_schedule" { | ||
for_each = var.create_table && length(var.schedule_scaling_indexes_read) > 0 ? var.autoscaling_indexes : {} | ||
source = "./module" | ||
|
||
name = "DynamoDBReadCapacityUtilization:${aws_appautoscaling_target.index_read[each.key].resource_id}" | ||
|
||
resource_id = aws_appautoscaling_target.index_read[each.key].resource_id | ||
scalable_dimension = aws_appautoscaling_target.index_read[each.key].scalable_dimension | ||
service_namespace = aws_appautoscaling_target.index_read[each.key].service_namespace | ||
|
||
schedule_scaling_indexes = var.schedule_scaling_indexes_read[each.key] | ||
} | ||
|
||
resource "aws_appautoscaling_scheduled_action" "table_write_schedule" { | ||
for_each = var.create_table && var.autoscaling_enabled && length(var.schedule_scaling_write) > 0 ? { for k, v in var.schedule_scaling_write : k => v } : {} | ||
|
||
name = "DynamoDBWriteCapacityUtilization:${aws_appautoscaling_target.table_write[0].resource_id}" | ||
|
||
resource_id = aws_appautoscaling_target.table_write[0].resource_id | ||
scalable_dimension = aws_appautoscaling_target.table_write[0].scalable_dimension | ||
service_namespace = aws_appautoscaling_target.table_write[0].service_namespace | ||
|
||
schedule = each.value["schedule"] | ||
|
||
scalable_target_action { | ||
max_capacity = each.value["max_capacity"] | ||
min_capacity = each.value["min_capacity"] | ||
} | ||
} | ||
|
||
module "index_write_schedule" { | ||
for_each = var.create_table && length(var.schedule_scaling_indexes_write) > 0 ? var.autoscaling_indexes : {} | ||
source = "./module" | ||
|
||
name = "DynamoDBWriteCapacityUtilization:${aws_appautoscaling_target.index_write[each.key].resource_id}" | ||
|
||
resource_id = aws_appautoscaling_target.index_write[each.key].resource_id | ||
scalable_dimension = aws_appautoscaling_target.index_write[each.key].scalable_dimension | ||
service_namespace = aws_appautoscaling_target.index_write[each.key].service_namespace | ||
|
||
schedule_scaling_indexes = var.schedule_scaling_indexes_write[each.key] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters