在RDS实例启动时创建EventBridge事件。

huangapple go评论79阅读模式
英文:

Creating event in eventbridge when an RDS instance is started

问题

  1. 我正在尝试学习并尝试使用AWS服务。我想在EventBridge中创建一个规则,当启动RDS数据库实例时,会简单地触发一个Lambda函数。
  2. 这是我使用的规则:
  3. {
  4. "version": "0",
  5. "detail-type": "RDS DB Instance Event",
  6. "source": "aws.rds",
  7. "region": "eu-south-2",
  8. "resources": ["XXX"],
  9. "detail": {
  10. "EventCategories": ["notification"],
  11. "SourceType": "DB_INSTANCE",
  12. "SourceArn": "XXX",
  13. "Message": "DB instance started.",
  14. "EventID": "RDS-EVENT-0088"
  15. }
  16. }
  17. 我收到一个错误消息:“事件模式无效。原因:“version”必须是对象或数组...”
  18. 我猜这是一个格式错误,但实在想不出...我只是传递一个字符串。当我尝试从[官方文档](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-cloud-watch-events.html)中测试模式时,我收到相同的错误。
  19. 这可能是一些非常愚蠢的事情,但我将非常感激您的帮助。
英文:

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:

  1. {
  2. "version": "0",
  3. "detail-type": "RDS DB Instance Event",
  4. "source": "aws.rds",
  5. "region": "eu-south-2",
  6. "resources": ["XXX"],
  7. "detail": {
  8. "EventCategories": ["notification"],
  9. "SourceType": "DB_INSTANCE",
  10. "SourceArn": "XXX",
  11. "Message": "DB instance started.",
  12. "EventID": "RDS-EVENT-0088"
  13. }
  14. }

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实例启动时生成的事件

  1. {
  2. "version": "0",
  3. "id": "68f6e973-1a0c-d37b-f2f2-94a7f62ffd4e",
  4. "detail-type": "RDS DB Instance Event",
  5. "source": "aws.rds",
  6. "account": "123456789012",
  7. "time": "2018-09-27T22:36:43Z",
  8. "region": "us-east-1",
  9. "resources": ["arn:aws:rds:us-east-1:123456789012:db:mysql-instance-2018-10-06-12-24"],
  10. "detail": {
  11. "EventCategories": ["failover"],
  12. "SourceType": "DB_INSTANCE",
  13. "SourceArn": "arn:aws:rds:us-east-1:123456789012:db:mysql-instance-2018-10-06-12-24e",
  14. "Date": "2018-09-27T22:36:43.292Z",
  15. "SourceIdentifier": "rds:mysql-instance-2018-10-06-12-24",
  16. "Message": "一个多AZ故障转移已经完成。", // 消息可能会有所不同
  17. "EventID": "RDS-EVENT-0088"
  18. }
  19. }
  • 创建一个自定义模式并使用以下JSON。
  1. {
  2. "source": ["aws.rds"],
  3. "detail-type": ["RDS DB Instance Event"],
  4. "detail": {
  5. "EventID": ["RDS-EVENT-0088"]
  6. }
  7. }

如果您测试这个规则,对于上面提到的事件,它将匹配。

如何找到示例事件[如评论所述]

在RDS实例启动时创建EventBridge事件。

英文:

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

    1. {
    2. "version": "0",
    3. "id": "68f6e973-1a0c-d37b-f2f2-94a7f62ffd4e",
    4. "detail-type": "RDS DB Instance Event",
    5. "source": "aws.rds",
    6. "account": "123456789012",
    7. "time": "2018-09-27T22:36:43Z",
    8. "region": "us-east-1",
    9. "resources": ["arn:aws:rds:us-east-1:123456789012:db:mysql-instance-2018-10-06-12-24"],
    10. "detail": {
    11. "EventCategories": ["failover"],
    12. "SourceType": "DB_INSTANCE",
    13. "SourceArn": "arn:aws:rds:us-east-1:123456789012:db:mysql-instance-2018-10-06-12-24e",
    14. "Date": "2018-09-27T22:36:43.292Z",
    15. "SourceIdentifier": "rds:mysql-instance-2018-10-06-12-24",
    16. "Message": "A Multi-AZ failover has completed.", // Message would be something else
    17. "EventID": "RDS-EVENT-0088"
    18. }
    19. }
  • create a custom pattern and use the following json.

    1. {
    2. "source": ["aws.rds"],
    3. "detail-type": ["RDS DB Instance Event"],
    4. "detail": {
    5. "EventID": ["RDS-EVENT-0088"]
    6. }
    7. }

If you test this rule, for the event above mentioned it will match.

how to find sample event [ as per comments ]

在RDS实例启动时创建EventBridge事件。

huangapple
  • 本文由 发表于 2023年7月12日 21:20:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76671051.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定