英文:
Creating event in eventbridge when an RDS instance is started
问题
我正在尝试学习并尝试使用AWS服务。我想在EventBridge中创建一个规则,当启动RDS数据库实例时,会简单地触发一个Lambda函数。
这是我使用的规则:
{
"version": "0",
"detail-type": "RDS DB Instance Event",
"source": "aws.rds",
"region": "eu-south-2",
"resources": ["XXX"],
"detail": {
"EventCategories": ["notification"],
"SourceType": "DB_INSTANCE",
"SourceArn": "XXX",
"Message": "DB instance started.",
"EventID": "RDS-EVENT-0088"
}
}
我收到一个错误消息:“事件模式无效。原因:“version”必须是对象或数组...”
我猜这是一个格式错误,但实在想不出...我只是传递一个字符串。当我尝试从[官方文档](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-cloud-watch-events.html)中测试模式时,我收到相同的错误。
这可能是一些非常愚蠢的事情,但我将非常感激您的帮助。
英文:
I am trying to learn and play a bit with aws serevices. I want to create a rule in the eventbridge that would simply lanch a lambda function when an rds database instance is started.
Here is the rule I use:
{
"version": "0",
"detail-type": "RDS DB Instance Event",
"source": "aws.rds",
"region": "eu-south-2",
"resources": ["XXX"],
"detail": {
"EventCategories": ["notification"],
"SourceType": "DB_INSTANCE",
"SourceArn": "XXX",
"Message": "DB instance started.",
"EventID": "RDS-EVENT-0088"
}
}
I get an error "Event pattern is not valid. Reason: "version" must be an object or an array at... "
I guess it is a formating error, but literally can't figure it out... I'm just passing a string. When I try to test the pattern from the official documentation I get the same error.
It is probably something very stupid, but I would greatly appreciate your help.
答案1
得分: 1
您的规则是错误的。
这不是规则,而是一个将被规则匹配的事件示例。
您可以通过以下方式创建规则:
-
转到事件桥,创建规则
-
选择事件源为AWS
-
选择示例事件类型为"输入自定义事件",并输入下面提到的事件(这是根据问题标题生成的事件,用于启动实例时生成的事件)。要查看其他事件ID,请参考文档
-
0088事件ID是RDS实例启动时生成的事件
{
"version": "0",
"id": "68f6e973-1a0c-d37b-f2f2-94a7f62ffd4e",
"detail-type": "RDS DB Instance Event",
"source": "aws.rds",
"account": "123456789012",
"time": "2018-09-27T22:36:43Z",
"region": "us-east-1",
"resources": ["arn:aws:rds:us-east-1:123456789012:db:mysql-instance-2018-10-06-12-24"],
"detail": {
"EventCategories": ["failover"],
"SourceType": "DB_INSTANCE",
"SourceArn": "arn:aws:rds:us-east-1:123456789012:db:mysql-instance-2018-10-06-12-24e",
"Date": "2018-09-27T22:36:43.292Z",
"SourceIdentifier": "rds:mysql-instance-2018-10-06-12-24",
"Message": "一个多AZ故障转移已经完成。", // 消息可能会有所不同
"EventID": "RDS-EVENT-0088"
}
}
- 创建一个自定义模式并使用以下JSON。
{
"source": ["aws.rds"],
"detail-type": ["RDS DB Instance Event"],
"detail": {
"EventID": ["RDS-EVENT-0088"]
}
}
如果您测试这个规则,对于上面提到的事件,它将匹配。
如何找到示例事件[如评论所述]
英文:
Your rule is wrong.
This is the not the rule but an example of event which will be matched by rule.
You can actually create a rule by doing the following:-
-
go to eventbridge , create rule
-
select event source as aws
-
choose sample events type as enter my own and enter the below mentioned event ( this is the event which is generated when instance is started as per title of questions). to check other event id, follow docs
-
0088 event id is the event when rds instance is started
{ "version": "0", "id": "68f6e973-1a0c-d37b-f2f2-94a7f62ffd4e", "detail-type": "RDS DB Instance Event", "source": "aws.rds", "account": "123456789012", "time": "2018-09-27T22:36:43Z", "region": "us-east-1", "resources": ["arn:aws:rds:us-east-1:123456789012:db:mysql-instance-2018-10-06-12-24"], "detail": { "EventCategories": ["failover"], "SourceType": "DB_INSTANCE", "SourceArn": "arn:aws:rds:us-east-1:123456789012:db:mysql-instance-2018-10-06-12-24e", "Date": "2018-09-27T22:36:43.292Z", "SourceIdentifier": "rds:mysql-instance-2018-10-06-12-24", "Message": "A Multi-AZ failover has completed.", // Message would be something else "EventID": "RDS-EVENT-0088" } }
-
create a custom pattern and use the following json.
{ "source": ["aws.rds"], "detail-type": ["RDS DB Instance Event"], "detail": { "EventID": ["RDS-EVENT-0088"] } }
If you test this rule, for the event above mentioned it will match.
how to find sample event [ as per comments ]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论