diff --git a/infrastructure/terraform/components/api/module_ddb_alarms_letter_queue.tf b/infrastructure/terraform/components/api/module_ddb_alarms_letter_queue.tf index 212b7d9ca..f099b6c54 100644 --- a/infrastructure/terraform/components/api/module_ddb_alarms_letter_queue.tf +++ b/infrastructure/terraform/components/api/module_ddb_alarms_letter_queue.tf @@ -4,4 +4,7 @@ module "ddb_alarms_letter_queue" { alarm_prefix = local.csi table_name = aws_dynamodb_table.letter_queue.name tags = local.default_tags + + write_throttle_evaluation_periods = 5 + write_throttle_datapoints_to_alarm = 3 } diff --git a/infrastructure/terraform/components/api/variables.tf b/infrastructure/terraform/components/api/variables.tf index 3d16b8465..8782cc428 100644 --- a/infrastructure/terraform/components/api/variables.tf +++ b/infrastructure/terraform/components/api/variables.tf @@ -226,6 +226,7 @@ variable "enable_alarms" { description = "Enable CloudWatch alarms for this deployed environment" default = true } + variable "deploy_supplier_mock_scheduler" { type = bool description = "Deploy EventBridge Scheduler trigger for supplier mock lambda" diff --git a/infrastructure/terraform/modules/alarms-ddb/README.md b/infrastructure/terraform/modules/alarms-ddb/README.md index b9c3b0c12..ed912741c 100644 --- a/infrastructure/terraform/modules/alarms-ddb/README.md +++ b/infrastructure/terraform/modules/alarms-ddb/README.md @@ -17,6 +17,9 @@ | [read\_throttle\_threshold](#input\_read\_throttle\_threshold) | n/a | `number` | `0` | no | | [table\_name](#input\_table\_name) | n/a | `string` | n/a | yes | | [tags](#input\_tags) | n/a | `map(string)` | `{}` | no | +| [write\_capacity\_threshold](#input\_write\_capacity\_threshold) | n/a | `number` | `48000` | no | +| [write\_throttle\_datapoints\_to\_alarm](#input\_write\_throttle\_datapoints\_to\_alarm) | n/a | `number` | `1` | no | +| [write\_throttle\_evaluation\_periods](#input\_write\_throttle\_evaluation\_periods) | n/a | `number` | `1` | no | | [write\_throttle\_threshold](#input\_write\_throttle\_threshold) | n/a | `number` | `0` | no | ## Modules diff --git a/infrastructure/terraform/modules/alarms-ddb/cloudwatch_metric_alarm_write_capacity.tf b/infrastructure/terraform/modules/alarms-ddb/cloudwatch_metric_alarm_write_capacity.tf new file mode 100644 index 000000000..4a065fd09 --- /dev/null +++ b/infrastructure/terraform/modules/alarms-ddb/cloudwatch_metric_alarm_write_capacity.tf @@ -0,0 +1,22 @@ +resource "aws_cloudwatch_metric_alarm" "write_capacity" { + alarm_name = "${var.alarm_prefix}-ddb-${var.table_name}-write-capacity" + alarm_description = "RELIABILITY: DynamoDB consumed write capacity approaching limit" + + namespace = "AWS/DynamoDB" + metric_name = "ConsumedWriteCapacityUnits" + statistic = "Sum" + period = var.period_seconds + + evaluation_periods = var.evaluation_periods + threshold = var.write_capacity_threshold + comparison_operator = "GreaterThanThreshold" + treat_missing_data = "notBreaching" + + dimensions = { TableName = var.table_name } + + actions_enabled = false + alarm_actions = [] + ok_actions = [] + insufficient_data_actions = [] + tags = var.tags +} diff --git a/infrastructure/terraform/modules/alarms-ddb/cloudwatch_metric_alarm_write_throttle.tf b/infrastructure/terraform/modules/alarms-ddb/cloudwatch_metric_alarm_write_throttle.tf index 8975e1efa..3ec913acd 100644 --- a/infrastructure/terraform/modules/alarms-ddb/cloudwatch_metric_alarm_write_throttle.tf +++ b/infrastructure/terraform/modules/alarms-ddb/cloudwatch_metric_alarm_write_throttle.tf @@ -7,7 +7,8 @@ resource "aws_cloudwatch_metric_alarm" "write_throttle" { statistic = "Sum" period = var.period_seconds - evaluation_periods = var.evaluation_periods + evaluation_periods = var.write_throttle_evaluation_periods + datapoints_to_alarm = var.write_throttle_datapoints_to_alarm threshold = var.write_throttle_threshold comparison_operator = "GreaterThanThreshold" treat_missing_data = "notBreaching" diff --git a/infrastructure/terraform/modules/alarms-ddb/variables.tf b/infrastructure/terraform/modules/alarms-ddb/variables.tf index 3895d21eb..2534bc678 100644 --- a/infrastructure/terraform/modules/alarms-ddb/variables.tf +++ b/infrastructure/terraform/modules/alarms-ddb/variables.tf @@ -21,6 +21,16 @@ variable "evaluation_periods" { default = 1 } +variable "write_throttle_evaluation_periods" { + type = number + default = 1 +} + +variable "write_throttle_datapoints_to_alarm" { + type = number + default = 1 +} + variable "read_throttle_threshold" { type = number default = 0 @@ -30,3 +40,8 @@ variable "write_throttle_threshold" { type = number default = 0 } + +variable "write_capacity_threshold" { + type = number + default = 48000 # 80% of 60k/min DynamoDB limit +}