EventBridge Partner Sources are the secret sauce for getting data out of SaaS providers and into AWS without you having to write a single line of code to poll their APIs.
Here’s a SaaS provider, let’s say Stripe, wanting to tell you when a new customer signs up. Instead of you writing a script to GET /v1/customers every 5 minutes, Stripe itself emits an event. EventBridge’s Partner Sources are the AWS-managed infrastructure that receives these events from Stripe and makes them available for you to consume. Think of it as a managed webhook endpoint that magically understands Stripe’s event format and routes it.
Let’s see this in action. Imagine you’re using AWS CodeCommit, and you want to trigger a Lambda function whenever code is pushed to your main branch.
First, you need to set up a partner event source. You’d go to the EventBridge console, under "Partner event sources," and find "CodeCommit." You’ll then associate it with your AWS account. AWS then tells CodeCommit (behind the scenes) "Hey, send events for this user to this account."
Once associated, you’ll create an EventBridge rule. This rule defines what events you’re interested in and where they should go.
Here’s a sample rule configuration in JSON:
{
"Source": [
"aws.codecommit"
],
"DetailType": [
"CodeCommit Repository State Change"
],
"Detail": {
"referenceType": [
"branch"
],
"referenceName": [
"main"
],
"event": [
"allCommit"
]
},
"EventBusName": "default"
}
And here’s the target for that rule – a Lambda function named CodeCommitBranchMonitor:
{
"Id": "CodeCommitBranchMonitorTarget",
"Arn": "arn:aws:lambda:us-east-1:123456789012:function:CodeCommitBranchMonitor",
"RoleArn": "arn:aws:iam::123456789012:role/EventBridgeInvokeLambdaRole"
}
When a commit happens on the main branch of any of your CodeCommit repositories, EventBridge picks it up. The rule matches the event’s Source ("aws.codecommit"), DetailType ("CodeCommit Repository State Change"), and the specific details about the referenceName being "main" and the event being "allCommit". This rule then triggers the target, invoking your CodeCommitBranchMonitor Lambda function.
The Lambda function receives an event payload that looks something like this:
{
"version": "0",
"id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"detail-type": "CodeCommit Repository State Change",
"source": "aws.codecommit",
"account": "123456789012",
"time": "2023-10-27T10:00:00Z",
"region": "us-east-1",
"resources": [
"arn:aws:codecommit:us-east-1:123456789012:my-repo"
],
"detail": {
"repositoryId": "my-repo",
"referenceType": "branch",
"referenceName": "main",
"commitId": "abcdef1234567890abcdef1234567890abcdef12",
"originatorArn": "arn:aws:iam::123456789012:user/Alice",
"event": "allCommit",
"beforeCommitId": "fedcba0987654321fedcba0987654321fedcba0",
"accountId": "123456789012"
}
}
Your Lambda function then parses this JSON, extracts the commitId, repositoryId, and other relevant information, and can perform actions like updating a dashboard, sending a Slack notification, or triggering a CI/CD pipeline.
The magic here is that the SaaS provider (CodeCommit, in this case) is the one pushing the event. You don’t need to poll. This is far more efficient and provides near real-time updates. EventBridge acts as the central nervous system, decoupling the event producer (CodeCommit) from the event consumer (your Lambda function).
What most people don’t realize is that you can create custom partner event sources. If a SaaS provider doesn’t have a direct integration, you can use their webhook capabilities to send events to EventBridge. You’d configure the SaaS provider to send a POST request to a specific EventBridge API endpoint, and EventBridge will ingest it as a custom event source, allowing you to apply the same rule-based routing.
The next step is often dealing with event filtering beyond the detail object, or managing event buses for different environments.