1
  1. I have an existing Lambda function.
  2. I can use the console to create a new Rule with my Lambda as the Target.
  3. When I do so via the console, it automatically creates a "EventBridge (CloudWatch Events)" Trigger which is visible on the Lambda configuration screen.
  4. The Rule executes and successfully invokes the Lambda.

Attempting to automate the above steps using C# and the SDK (nuget package: AWSSDK.EventBridge), I take the following steps:

  1. I call PutRule successfully.
  2. I call PutTarget successfully

The Rule & Target look perfectly normal and functional in the EventBridge console, but the Trigger does not appear on the Lambda function at all and the Lambda is never invoked by the Rule.

If I now edit the Rule, don't change anything but just click Update in the console, it wires it up successfully with a Trigger.

I'm guessing it is one of two scenarios:

  1. I need to add an additional request to my code - something like PutTriggerOnLambda
  2. Or I am simply missing IAM permissions and it is failing silently

Anyone have a suggestion?

1
  • Is there any specific requirement because of which you want to do it via code. This can be very well achieved vi CFN Commented Apr 30, 2021 at 14:21

1 Answer 1

1

I got some really good technical support from AWS and learned that the step I was missing was to Add Permission to the lambda function to allow the Event Bridge Rule to trigger it.

This doc explains the situation: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CWE_Troubleshooting.html#LAMfunctionNotInvoked

This doc 2.2 explains the missing step via CLI: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html

And this doc explains how to do it via SDK: https://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.