Reputation: 41
I am trying to create cloudwatch alarams for LB using terraform using below code. I am getting an error An argument named "alb_arn_suffix" is not expected here.
here is the sample code which i am using.
resource "aws_cloudwatch_metric_alarm" "this" {
alarm_name = "alb-alarams"
alarm_description = "unhealthy"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 1
threshold = 1
period = 60
unit = "Count"
namespace = "ALB"
metric_name = "UnHealthyHostCount"
statistic = "Sum"
alb_arn_suffix = ["arn:aws:elasticloadbalancing:eu-west-2:124531745575:loadbalancer/app/alb-
123/1cd382a00a565a8b"]
alarm_actions = ["arn:aws:sns:eu-west-2:124531745575:alb-alerts"]
dimensions = {
Name="ALB"
Value="test"
}
Please advise.
Upvotes: 3
Views: 2830
Reputation: 238517
There are several issues with your aws_cloudwatch_metric_alarm
.
alb_arn_suffix
is invalid, thus error.dimensions
are also incorrectnamespace
is sadly also wrong.UnHealthyHostCount
metric is part of AWS/ApplicationELB namespace, which has only two set of dimensions:
Assuming that you would use first set, aws_cloudwatch_metric_alarm
would be something like the following:
resource "aws_cloudwatch_metric_alarm" "this" {
alarm_name = "alb-alarams"
alarm_description = "unhealthy"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 1
threshold = 1
period = 60
unit = "Count"
namespace = "AWS/ApplicationELB"
metric_name = "UnHealthyHostCount"
statistic = "Sum"
alarm_actions = ["arn:aws:sns:eu-west-2:124531745575:alb-alerts"]
dimensions = {
TargetGroup = aws_lb_target_group.lb-tg.arn_suffix
LoadBalancer = aws_lb.lb.arn_suffix
}
}
You would have to substitute aws_lb_target_group
and aws_lb
for your values.
Upvotes: 5