- Newest
- Most votes
- Most comments
It seems you're trying to set up notifications for user import job events in Amazon Cognito using EventBridge. While your approach is on the right track, there are a few things to consider and potentially adjust in your setup:
-
Event pattern: Your event pattern looks correct for capturing the StartUserImportJob and StopUserImportJob events from Cognito. However, these events might not provide all the details you're looking for regarding the import status and number of skipped users.
-
CloudTrail integration: You mentioned seeing logs in CloudTrail. This is because Cognito user import job events are typically logged in CloudTrail. EventBridge can capture these CloudTrail events, but you may need to adjust your rule.
-
Custom email notifications: To send custom email notifications with detailed information about the import job, you might need to combine EventBridge with a Lambda function and possibly query the Cognito API for additional details.
Here's a suggested approach:
- Create an EventBridge rule that captures CloudTrail events for Cognito user import jobs. The event pattern might look like this:
{ "source": ["aws.cognito-idp"], "detail-type": ["AWS API Call via CloudTrail"], "detail": { "eventSource": ["cognito-idp.amazonaws.com"], "eventName": ["StartUserImportJob", "StopUserImportJob"] } }
-
Set up a Lambda function as the target for this EventBridge rule. This function can:
- Parse the event details
- Query the Cognito API for additional information about the import job status
- Format and send an email to the admin using Amazon SES or SNS
-
In your Lambda function, you can use the Cognito API (DescribeUserImportJob) to get detailed information about the import job, including the number of users imported, failed, and skipped.
-
Use Amazon SES or SNS to send the formatted email to the admin.
By following this approach, you should be able to capture the Cognito user import events and send detailed notifications to the admin about the file upload status, including information about skipped users and overall success or failure.
Remember to ensure that your Lambda function has the necessary permissions to access Cognito, CloudWatch Logs, and the email service you choose (SES or SNS).
If you're still not seeing the events in EventBridge, double-check that CloudTrail is enabled for your account and that it's logging Cognito events. Also, verify that your EventBridge rule is in the same region as your Cognito user pool.
Sources
Responding to an event with a Lambda function - AWS Certificate Manager
Configuring an EventBridge rule to send notifications about events in AWS Health - AWS Health
Custom email sender Lambda trigger - Amazon Cognito
answered 2 years ago
Relevant content
asked 4 years ago
asked 4 years ago
