【问题标题】:Terraform: Cloudwatch Canary Synthetics, How to create metric alarmTerraform:Cloudwatch Canary Synthetics,如何创建指标警报
【发布时间】:2021-08-08 18:24:32
【问题描述】:

我尝试为我的 Canary 资源创建警报。我找不到在我的资源中为aws_cloudwatch_metric_alarm 引用我的金丝雀的解决方案。在控制台中有一个参数CanaryName

我可以使用以下方法创建我的金丝雀:

resource "aws_synthetics_canary" "some" {
  name                 = "some-canary"
  artifact_s3_location = "s3://some-bucket/"
  execution_role_arn   = "some-role"
  handler              = "exports.handler"
  zip_file             = "test-fixtures/lambdatest.zip"
  runtime_version      = "syn-1.0"

  schedule {
    expression = "rate(0 minute)"
  }
}

使用aws_cloudwatch_metric_alarm,我想为关联的金丝雀创建警报,但我缺少像 CanaryName 这样的参数:

resource "aws_cloudwatch_metric_alarm" "foobar" {
  alarm_name                = "terraform-test-foobar5"
  comparison_operator       = "GreaterThanOrEqualToThreshold"
  evaluation_periods        = "2"
  metric_name               = "CPUUtilization"
  namespace                 = "AWS/EC2"
  period                    = "120"
  statistic                 = "Average"
  threshold                 = "80"
  alarm_description         = "This metric monitors ec2 cpu utilization"
  insufficient_data_actions = []
}

命名空间 CloudWatchSynthetics 正在运行

知道如何解决这个问题吗?

谢谢!

类似问题:https://discuss.hashicorp.com/t/aws-cloudwatch-metric-alarm/14396

【问题讨论】:

  • 这是最近添加到 CloudWatch 的吗?
  • 您能展示一下您的尝试吗?如果没有看到 Terraform 代码和/或您在 AWS 控制台中复制它所做的工作,很难知道您遇到了什么问题。你也看过registry.terraform.io/providers/hashicorp/aws/latest/docs/…docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/…吗?
  • @MarkoE 我认为这不是超级新的,但是去年 11 月添加了一些功能(例如环境变量),并且在 terraform 的 GitHub 存储库中打开了一些紧急功能请求
  • @ydaetskcoR 是的,对不起,我会编辑问题
  • 好吧,您粘贴了 Terraform 示例。您能否分享您的代码,删除任何敏感信息,例如存储桶名称?

标签: amazon-web-services terraform amazon-cloudwatch


【解决方案1】:
  dimensions = {
    CanaryName = "NAME_OF_CANARY"
  }

这就是您引用金丝雀名称的方式:-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-07
    • 1970-01-01
    • 1970-01-01
    • 2020-12-20
    • 2021-06-23
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多