简体   繁体   English

将 Event Bridge 计划事件中的自定义参数传递给 lambda

[英]Pass custom parameters in Event Bridge schedule event to lambda

I have a Lambda function which gets invoked at a fixed schedule from EventBridge events.我有一个 Lambda function 从 EventBridge 事件中以固定的时间表调用它。 Is there any way to pass custom parameters(like a json file) to the invoked lambda function via an event rule?有什么方法可以通过事件规则将自定义参数(如 json 文件)传递给调用的 lambda function 吗?

I tried passing a json string inside withEventPattern in the PutRule object, like this:我尝试在 PutRule object 中的 withEventPattern 中传递一个 json 字符串,如下所示:

{'detail': {"id": ["unique_id"]}} => this lead to this error: {'detail': {"id": ["unique_id"]}} => 这导致了这个错误:

"Event pattern is not valid. Reason: Unrecognized match type instance-id\n at [Source: (String)\"{\"detail\":[{\"instance-id\":[\"d1983a77-dc0e-4724-953f-df283c1ad421\"]}]}\"

I understand this is not the appropriate way of doing this, but I was trying my luck.我知道这不是这样做的合适方法,但我是在碰运气。

If you use scheduled-events to trigger a lambda function then you should be able to use InputTransformer to add whatever static data you want to have delivered to the lambda (see: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html )如果您使用预定事件触发 lambda function 那么您应该能够使用 InputTransformer 添加您想要传送到 lambda 的任何 static 数据(请参阅: https://docs.aws.amazonlatest.com/eventbridgezon.com/eventbridgezonlatest /userguide/eb-transform-target-input.html )

When you create the EventBridge rule, you can specify JSON to pass for the event.当您创建 EventBridge 规则时,您可以指定 JSON 为事件传递。 Under "Additional settings" you can configure the target input, and one option is JSON. The following shows this in the console, and similar options are available if you create the rule via the APIs or CloudFormation:在“其他设置”下,您可以配置目标输入,其中一个选项是 JSON。控制台中显示了以下内容,如果您通过 API 或 CloudFormation 创建规则,则可以使用类似的选项: 在此处输入图像描述

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

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