seahaven-door-unlock-api/terraform/alarms.tf
Adam Moussa c43bee214c
feat(terraform): add hcp terraform for prod door-unlock-api (PLAT-76) (#81)
* feat(terraform): add hcp terraform for prod door-unlock-api

Move deploy off frozen CDK CD onto an HCP workspace that recreates the HTTP API, five Lambdas, disabled EventBridge rules, and alarms in seahaven-prod without a poller VPC.

* docs(readme): link the door unlock api ops page

* fix(terraform): invoke package build via bash

HCP launches the external data source with bash, so the inner build script should not depend on the git executable bit.
2026-08-27 22:03:12 +00:00

44 lines
1.6 KiB
HCL

locals {
alarm_functions = {
unlock = {
function_name = aws_lambda_function.unlock.function_name
description = "door-unlock-api-unlock Lambda is erroring — physical door unlock calls may be failing"
}
lockdown = {
function_name = aws_lambda_function.lockdown.function_name
description = "door-unlock-api-lockdown Lambda is erroring — lockdown commands may not be executing"
}
authorizer = {
function_name = aws_lambda_function.authorizer.function_name
description = "door-unlock-api-authorizer Lambda is erroring — all API requests will be rejected"
}
poller = {
function_name = aws_lambda_function.poller.function_name
description = "door-unlock-api-lockdown-poller Lambda is erroring — lockdown state polling may be broken"
}
blf_sync = {
function_name = aws_lambda_function.blf_sync.function_name
description = "door-unlock-api-blf-sync Lambda is erroring — department BLF updates may not be applying"
}
}
}
resource "aws_cloudwatch_metric_alarm" "lambda_errors" {
for_each = local.alarm_functions
alarm_name = "${each.value.function_name}-errors"
alarm_description = each.value.description
namespace = "AWS/Lambda"
metric_name = "Errors"
statistic = "Sum"
period = 300
evaluation_periods = 1
threshold = 0
comparison_operator = "GreaterThanThreshold"
treat_missing_data = "notBreaching"
alarm_actions = [data.aws_sns_topic.site_alerts.arn]
dimensions = {
FunctionName = each.value.function_name
}
}