问题描述
我正在尝试创建一个由不同 AWS 账户中 S3 存储桶中的文件更改触发的事件规则.详细说明在这里
到目前为止,该规则适用于确切的文件名,但我需要使其适用于文件名前缀.在工作示例中,文件名是一个确切的字符串,在非工作示例中,文件名是通配符.CloudWatch Events 规则 JSON 模式是否支持通配符?
工作配置:
{来源":[aws.s3"],帐户":[1111111xxxxx"],细节": {事件来源":[s3.amazonaws.com"],事件名称":[放置对象"],"requestParameters": { "bucketName": ["mybucket"], "key": ["myfile-20180301.csv"] }}}
非工作配置:
{来源":[aws.s3"],帐户":[1111111xxxxx"],细节": {事件来源":[s3.amazonaws.com"],事件名称":[放置对象"],"requestParameters": { "bucketName": ["mybucket"], "key": ["myfile-*"] }}}
我使用 基于内容的过滤(2020 年 2 月发布),例如 prefix.>
所以在你的情况下,解决方案应该是:
{来源":[aws.s3"],帐户":[1111111xxxxx"],细节": {事件来源":[s3.amazonaws.com"],事件名称":[放置对象"],请求参数":{"bucketName": ["mybucket"],"key": [{ "prefix": "myfile-" }]}}}
I am trying to create an event rule that is triggered by a change in a file in S3 bucket in different AWS account. Detail description is here
So far the rule works fine with exact file names, but I need to make it work with filename prefixes. In the working example, the file name is an exact string in the non-working example the file name is a wildcard. Does CloudWatch Events Rule JSON pattern supports wildcards?
Working configuration:
{
"source": ["aws.s3"],
"account": ["1111111xxxxx"],
"detail": {
"eventSource": ["s3.amazonaws.com"],
"eventName": ["PutObject"],
"requestParameters": { "bucketName": ["mybucket"], "key": ["myfile-20180301.csv"] }
}
}
Non-working configuration:
{
"source": ["aws.s3"],
"account": ["1111111xxxxx"],
"detail": {
"eventSource": ["s3.amazonaws.com"],
"eventName": ["PutObject"],
"requestParameters": { "bucketName": ["mybucket"], "key": ["myfile-*"] }
}
}
I found a fancy solution for this using Content-based filtering (released in February 2020) like prefix for example.
So in your case, the solution should be:
{
"source": ["aws.s3"],
"account": ["1111111xxxxx"],
"detail": {
"eventSource": ["s3.amazonaws.com"],
"eventName": ["PutObject"],
"requestParameters": {
"bucketName": ["mybucket"],
"key": [{ "prefix": "myfile-" }]
}
}
}
这篇关于AWS CloudWatch Events Rule 是否支持 S3 存储桶/键名称中的任何通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!