Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions infrastructure/terraform/components/api/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions infrastructure/terraform/modules/alarms-ddb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
| <a name="input_read_throttle_threshold"></a> [read\_throttle\_threshold](#input\_read\_throttle\_threshold) | n/a | `number` | `0` | no |
| <a name="input_table_name"></a> [table\_name](#input\_table\_name) | n/a | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(string)` | `{}` | no |
| <a name="input_write_capacity_threshold"></a> [write\_capacity\_threshold](#input\_write\_capacity\_threshold) | n/a | `number` | `48000` | no |
| <a name="input_write_throttle_datapoints_to_alarm"></a> [write\_throttle\_datapoints\_to\_alarm](#input\_write\_throttle\_datapoints\_to\_alarm) | n/a | `number` | `1` | no |
| <a name="input_write_throttle_evaluation_periods"></a> [write\_throttle\_evaluation\_periods](#input\_write\_throttle\_evaluation\_periods) | n/a | `number` | `1` | no |
| <a name="input_write_throttle_threshold"></a> [write\_throttle\_threshold](#input\_write\_throttle\_threshold) | n/a | `number` | `0` | no |
## Modules

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions infrastructure/terraform/modules/alarms-ddb/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Loading