如何创建 Cloudfront 控制台警报 Terraform
How to create Cloudfront Console Alarm Terraform
创建云监视警报:
resource "aws_cloudwatch_metric_alarm" "cloudfront-500-errors" {
alarm_name = "${var.ENVIRONMENT_NAME}-AWS-CloudFront-High-5xx-Error-Rate"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 1
metric_name = "5xxErrorRate"
namespace = "AWS/Cloudfront"
period = 60
statistic = "Average"
threshold = 5
treat_missing_data = "notBreaching"
alarm_actions = [aws_sns_topic.my-sns-topic.arn]
actions_enabled = true
dimensions = {
DistributionId = aws_cloudfront_distribution.this.id
Region = "Global"
}
}
我可以在 terraform 中为 cloudwatch 创建警报,但是如何在 "Cloudfront" 中获取警报?
这个问题的答案是,这个 UI 实际上只是对 cloudwatch 指标的 link。真正的问题是我的命名空间是:
namespace = "AWS/Cloudfront"
它需要是:
namespace = "AWS/CloudFront"
创建云监视警报:
resource "aws_cloudwatch_metric_alarm" "cloudfront-500-errors" {
alarm_name = "${var.ENVIRONMENT_NAME}-AWS-CloudFront-High-5xx-Error-Rate"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 1
metric_name = "5xxErrorRate"
namespace = "AWS/Cloudfront"
period = 60
statistic = "Average"
threshold = 5
treat_missing_data = "notBreaching"
alarm_actions = [aws_sns_topic.my-sns-topic.arn]
actions_enabled = true
dimensions = {
DistributionId = aws_cloudfront_distribution.this.id
Region = "Global"
}
}
我可以在 terraform 中为 cloudwatch 创建警报,但是如何在 "Cloudfront" 中获取警报?
这个问题的答案是,这个 UI 实际上只是对 cloudwatch 指标的 link。真正的问题是我的命名空间是:
namespace = "AWS/Cloudfront"
它需要是:
namespace = "AWS/CloudFront"