Skip to content

Why am I not receiving Cognito events in EventBridge?

0

I’m trying to trigger a Lambda function via EventBridge whenever a user is created in Amazon Cognito using the AdminCreateUser API (from the AWS Console). I have confirmed that CloudTrail is logging the event. I created the following EventBridge rule:

{
  "source": ["aws.cognito-idp"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["cognito-idp.amazonaws.com"]
  }
}

However, no events are being captured by this rule.

Is there something wrong with the event pattern, or is there an additional configuration required to get events into EventBridge from Cognito?

Thanks in advance!

  • Rule looks good. Have you tried to use CW logs as a target? To discard whether there is something wrong when invoking your function.

3 Answers
0

Hello.

Do you have a CloudTrail trail enabled in the region where your Cognito user pool is configured?
I tried the EventBridge rule you created in my AWS account, but EventBridge was not triggered unless a CloudTrail trail was enabled.
https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-a-trail-using-the-console-first-time.html

EXPERT

answered a year ago

  • Cloudtrail is always on but does eventbridge require a trail to be configured? I didnt think it did

  • Yes. CloudTrail won't deliver events to EventBridge, unless a trail logging at least the desired events is configured in the region. The default CloudTrail event history doesn't count as a trail.

  • In my testing, I found that a CloudTrail trail had to be enabled in order for EventBridge to catch the "AdminCreateUser" event.

0

There are several potential reasons why your EventBridge rule isn't capturing Cognito events despite them appearing in CloudTrail. Let me help you troubleshoot:

  1. Your event pattern looks correct for capturing Amazon Cognito user pool events. The source "aws.cognito-idp" and eventSource "cognito-idp.amazonaws.com" are the proper values for matching Cognito user pool events.

  2. To specifically target user creation events, you might want to add the "eventName" field to your pattern:

{
"source": ["aws.cognito-idp"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventSource": ["cognito-idp.amazonaws.com"],
"eventName": ["AdminCreateUser"]
}
}
  1. Check if your rule is in the "ENABLED" state. Disabled rules won't match any events.

  2. Verify that you've created the rule in the correct AWS region. Some AWS services may only send events to EventBridge in specific regions.

  3. Ensure that EventBridge has the necessary permissions to access the events and invoke your Lambda function.

  4. Allow some time for newly created or modified rules to become fully operational. There can sometimes be a slight delay.

  5. Verify that your CloudTrail trail is properly configured to send events to EventBridge.

  6. Check CloudWatch metrics for your EventBridge rule, such as "TriggeredRules" and "FailedInvocations" to get more insight into what's happening.

If the issue persists, consider setting up a dead-letter queue (DLQ) to capture any failed event deliveries for further analysis.
Sources
Amazon Cognito user pools events - Amazon EventBridge
Need some help with my setting(EventBridge) | AWS re:Post
EventBridge rule not triggered | AWS re:Post
Troubleshooting Amazon EventBridge - Amazon EventBridge

answered a year ago

EXPERT

reviewed a year ago

0

This works perfectly for me.

Make sure the role has access to the Target etc Also note, it can take a few mins for the rule to become active after you have created it.

{
  "detail-type": ["AWS API Call via CloudTrail"],
  "source": ["aws.cognito-idp"],
  "detail": {
    "eventName": ["AdminCreateUser"],
    "eventSource": ["cognito-idp.amazonaws.com"]
  }
}
EXPERT

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.