简体   繁体   English

Cloudwatch:用于监控 S3 文件的事件类型语法

[英]Cloudwatch: event type syntax for monitoring S3 files

I need to create a cloudwatch event that runs a lambda function everytime my file in S3 gets updated/re-uploaded.我需要创建一个运行 lambda function 的 cloudwatch 事件,每次我在 S3 中的文件得到更新/重新上传。 What "eventName" should I use?我应该使用什么“eventName”? I tried using "ObjectCreated" but it doesn't seem to work.我尝试使用“ObjectCreated”,但它似乎不起作用。 Perhaps the syntax is incorrect.也许语法不正确。

https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html

{
  "source": [
    "aws.s3"
  ],
  "detail-type": [
    "AWS API Call via CloudTrail"
  ],
  "detail": {
    "eventSource": [
      "s3.amazonaws.com"
    ],
    "eventName": [ "ObjectCreated:*"],
    "requestParameters": {
      "bucketName": [
        "mynewbucket"
      ],
      "key": [
        "file.csv"
      ]
    }
  }
}

CloudWatch Events (or EventBridge) does not automatically track data events for S3 objects. CloudWatch Events(或 EventBridge)不会自动跟踪 S3 对象的数据事件。 You need to either use CloudTrail for this, which tracks data events on a particular S3 bucket and emits CloudWatch Events (or EventBridge) events for that: https://aws.amazon.com/blogs/compute/using-dynamic-amazon-s3-event-handling-with-amazon-eventbridge/您需要为此使用 CloudTrail,它跟踪特定 S3 存储桶上的数据事件并为此发出 CloudWatch Events(或 EventBridge)事件: https://aws.amazon.com/blogs/compute/using-dynamic-amazon- s3-event-handling-with-amazon-eventbridge/

Or you can use S3 Event Notifications with an SNS topic and use a Lambda subscription on the SNS topic.或者,您可以将S3 事件通知与 SNS 主题一起使用,并在 SNS 主题上使用 Lambda 订阅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM