简体   繁体   English

AWS EventBridge 规则忽略键前缀和后缀匹配

[英]AWS EventBridge Rule Ignoring Key Prefix & Suffix Matching

I have an Event Bridge rule created where when I drop a file into an S3 bucket it will trigger a Step function.我创建了一个事件桥规则,当我将文件放入 S3 存储桶时,它将触发步骤 function。

I only want to trigger this rule when:我只想在以下情况下触发此规则:

  • A file is in a folder called files/ ( prefix: "files/" )文件位于名为files/的文件夹中( prefix: "files/"
  • The file is a CSV ( suffix: ".csv" )该文件是一个 CSV( suffix: ".csv"

However this rule is being triggered for any files regardless of their suffix and prefix.但是,无论文件的后缀和前缀如何,都会为任何文件触发此规则。 For instance I dropped a.pdf file in and it triggered the step function.例如,我放入了一个 .pdf 文件,它触发了步骤 function。

    {
      "detail-type": ["Object Created"],
      "source": ["aws.s3"],
      "detail": {
        "bucket": {
          "name": ["my-files-bucket"]
        },
        "object": {,
          "key": [{
            "prefix": "files/"
          }, {
            "suffix": ".csv"
          }]
        }
      }
    }

This is the expected behaviour.这是预期的行为。 EventBridge treats multiple values in brackets as an OR condition . EventBridge 将括号中的多个值视为OR 条件 Events will match your pattern if the object key begins with files/ OR ends with .csv .如果 object 键以files/开头或以.csv结尾,事件将匹配您的模式。

As far as I know, it's not possible to apply an AND condition to a single field.据我所知,不可能将 AND 条件应用于单个字段。

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

相关问题 为什么 AWS EventBridge 规则不支持后缀匹配? - Why AWS EventBridge Rules does not support Suffix Matching? 具有环境变量的 AWS Batch 的 AWS Cloudwatch (EventBridge) 事件规则 - AWS Cloudwatch (EventBridge) Event Rule for AWS Batch with Environment Variables 如何使用 AWS CDK 为带有别名的 Lambda 设置 EventBridge 规则目标 - How to use AWS CDK to set EventBridge Rule Target for Lambda with Alias 在 EventBridge 规则中为 AWS Batch 作业指定共享标识符 - Specifying Share Identifier in EventBridge rule for an AWS Batch job 一旦处理完所有进行中的 sqs 消息,AWS Eventbridge 规则就会触发 - AWS Eventbridge rule trigger once all in-flight sqs messages are processed AWS EventBridge 规则未触发:错误。 NotAuthorizedForSourceException。 未授权来源 - AWS EventBridge rule doesn't trigger: Error. NotAuthorizedForSourceException. Not authorized for the source AWS EventBridge 等待事件 - AWS EventBridge wait on event AWS EventBridge 作为 Lambda 目的地 - AWS EventBridge as Lambda destination AWS Eventbridge:如何手动运行计划规则(以便对其进行测试)? - AWS Eventbridge: how do I run a scheduled rule manually (in order to test it)? EventBridge 规则“除此之外”模式 - EventBridge rule "anything-but" pattern
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM