【问题标题】:Terraform AWS Cloudwatch Rule with Event Pattern incorrectly updatedTerraform AWS Cloudwatch 规则与事件模式错误更新
【发布时间】:2021-10-20 04:56:27
【问题描述】:

我正在尝试配置将触发 sns 主题的 cloudwatch 事件规则。 我一直面临从 cloutwatch 规则触发 sns 主题的问题,事件模式是从 terraform 创建的。以下是我的 terraform 代码:​​

resource "aws_cloudwatch_event_rule" "s3-event" {
  name        = "s3-event"
  description = "Capture each AWS s3 event"

  event_pattern = <<EOF
{
  "source": ["aws.s3"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["s3.amazonaws.com"],
    "eventName": ["CreateBucket"]
  }
}
EOF
}

在 aws ui 上应用选中的事件模式后,它看起来像:

Event pattern
{
  "detail": {
    "eventName": ["CreateBucket"],
    "eventSource": ["s3.amazonaws.com"]
  },
  "detail-type": ["AWS API Call via CloudTrail"],
  "source": ["aws.s3"]
}

IT 在创建 s3 存储桶时出现调用失败错误。 然后我从 aws 控制台重新保存:

{
  "source": ["aws.s3"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["s3.amazonaws.com"],
    "eventName": ["CreateBucket"]
  }
}

然后它通过了。

有人可以建议我如何禁用 terraform 以重新排列事件模式。

【问题讨论】:

    标签: amazon-web-services terraform0.12+


    【解决方案1】:

    当我默认从 terraform 创建 cloudwatch 事件时,重新排列模式不是解决方案在 terraform 中定义访问策略,如下所示并附加到 sns 主题:

    statement {
        effect  = "Allow"
        actions = ["SNS:Publish"]
    
        principals {
          type        = "Service"
          identifiers = ["events.amazonaws.com"]
        }
    

    【讨论】:

      猜你喜欢
      • 2019-08-27
      • 2019-07-15
      • 2022-11-03
      • 2017-11-01
      • 1970-01-01
      • 2020-09-20
      • 1970-01-01
      • 2020-07-27
      • 1970-01-01
      相关资源
      最近更新 更多