Why can't I view the EventBridge trigger in my Lambda function that my CloudFormation stack created?

2 minute read
0

I want to see the Amazon EventBridge event rule trigger in my AWS Lambda function that the AWS CloudFormation stack created.

Short description

When you create the AWS::Events::Rule and AWS::Lambda::Function resources through the CloudFormation stack, you might not see the event rule trigger on the Lambda console. This usually happens when EventBridge doesn't have permission to invoke the Lambda function. It can also happen when the event rule resource is deleted from outside the CloudFormation stack.

Resolution

EventBridge doesn't have permission to invoke the Lambda function

Use the AWS::Lambda::Permission resource in the CloudFormation stack to add the lambda:InvokeFunction permission to the resource-based policy of your target Lambda function.

For example, use the following resource to grant permission to the EventRule resource to invoke the Lambda function:

PermissionForEventsToInvokeLambda:   
  Type: AWS::Lambda::Permission  
  Properties:   
    FunctionName: !Ref LambdaFunction    
    Action: lambda:InvokeFunction  
    Principal: events.amazonaws.com  
    SourceArn: !GetAtt EventRule.Arn   
     

After you grant permission, the event rule trigger appears in the Lambda console.

The event rule resource is deleted from outside the CloudFormation stack

When an EventBridge event rule is deleted from outside the CloudFormation stack, the event rule doesn't appear in the Lambda trigger. 

To resolve this issue, change the resource's logical ID in the template to recreate the resource.

Related information

AWS::Lambda::Permission

Invoke Lambda function in response to an event

AWS OFFICIAL
AWS OFFICIALUpdated a month ago