Pass additional parameters to cron destination

0

I have 5 crons which have separate destination lambdas. All lambdas do same work except they just pass a different parameter to a common downstream. Currently there is no way to pass additional parameter alongside cron so that I can have 1 lambda as destination for 5 crons instead of 5 different ones. Can you add this feature?

2개 답변
1

Hi, I assume you created your cron using an eventbridge rule. If that's the case, and you trigger all 5 lambdas using the exact same cron schedule, and your parameters are fixed, did you try the following?

  • on your eventbridge rule, create 5 targets
  • every target calls your lambda
  • in every target, open the additional settings panel, set "configure target input" to "Constant (json text)", and in the "Specify the constant in JSON" editor, add the parameters you need to pass to your lambda, e.g. {"region": "eu-west-1", "myParam": "paramValue" }
  • in your lambda, read the parameters that you have set in the eventbridge rule using the event input

Example using the ruby language

def lambda_handler(event:, context:)
    symbol_event = JSON.parse(JSON[event], symbolize_names: true)
    puts symbol_event[:region]
end

Hope that's what you're looking for. If not, please let me know what I missed in your case.

profile pictureAWS
Jsc
답변함 2년 전
0

You can configure the payload that will be sent to the targets by specifying a Constant json object. Each target will have a different value.

profile pictureAWS
전문가
Uri
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠