carlos / platform Public

infra: use aws_region.region (v6 attr) + tag/describe the recover alarm

Review fix: data.aws_region.current.name is deprecated under the
module's hashicorp/aws >= 6.0 pin in favour of .region. Also adds
alarm_description and a Name tag on host_auto_recover, matching the
neighbouring resources' tagging convention.
Paul Campbell 69271521fa5168c16ab013d7559645cb3aa2b5dd parent 3c3fadb
1 file changed, +3 −1
  • infra/modules/region-host/main.tf +3 −1
diff --git a/infra/modules/region-host/main.tf b/infra/modules/region-host/main.tf
index 8c0966392..aaa4af923 100644
--- a/infra/modules/region-host/main.tf
+++ b/infra/modules/region-host/main.tf
@@ -188,6 +188,7 @@ resource "aws_eip" "host" {
resource "aws_cloudwatch_metric_alarm" "host_auto_recover" {
count = var.enable_auto_recovery ? 1 : 0
alarm_name = "${var.name}-auto-recover"
+ alarm_description = "EC2 system-status-check failure — auto-recovers ${var.name} onto healthy hardware."
namespace = "AWS/EC2"
metric_name = "StatusCheckFailed_System"
statistic = "Maximum"
@@ -195,8 +196,9 @@ resource "aws_cloudwatch_metric_alarm" "host_auto_recover" {
evaluation_periods = 2
threshold = 1
comparison_operator = "GreaterThanOrEqualToThreshold"
- alarm_actions = ["arn:aws:automate:${data.aws_region.current.name}:ec2:recover"]
+ alarm_actions = ["arn:aws:automate:${data.aws_region.current.region}:ec2:recover"]
dimensions = {
InstanceId = aws_instance.host.id
}
+ tags = { Name = "${var.name}-auto-recover" }
}