Amazon EventBridge

Amazon EventBridge is a serverless event bus that distributes events to connect application components and build highly scalable, resilient, event-driven applications. It provides a simple way to consume BigCommerce webhook events at scale, and it is an alternative to HTTPS and Google Cloud Pub/Sub delivery.

To deliver webhooks to Amazon EventBridge, complete the following steps:

Prerequisites

To send the following GraphQL queries and view responses, import the examples into Postman or any other tool that supports GraphQL queries. Set the following variables before you start:

CredentialsVariables
Store variableszone
store_hash
OAuth credentialsclient_id

GraphQL Admin API endpoints use the X-Auth-Token header to authenticate to BigCommerce servers. To call the Admin GraphQL API, use an API client tool such as Postman.

Set up an event source

Setting up an event source with EventBridge lets you send event data directly to Amazon services instead of receiving that traffic yourself through a front-end web server. Create an event source with the createEventSource mutation.

Example query: Create Amazon event source
POST https://{{zone}}/stores/{{store_hash}}/graphql
mutation createEventSource($input: CreateEventSourceInput!){
webhook {
createEventSource(input: $input) {
eventSource {
id
awsAccount
arn
eventSourceName
eventSourceRegion
}
}
}
}
GraphQL variables
{
"input" : {
"awsAccount": "649666292244",
"eventSourceName": "Final-Test-1",
"eventSourceRegion": "US_EAST_1",
"clientId": "4yk6pb824t53hirbuz5akdr652lpjb2"
}
}

Make note of the event_source_arn and event_source_name

Obtain the event_source_arn and event_source_name from the createEventSource mutation response. You use these values in the following steps, so save them as environment variables in Postman.

Associate an event bus

Next, associate the event source with an event bus:

Example query: Create an Amazon event bus
POST https://events.{{region}}.amazonaws.com/?Action=CreateEventBus&Version=2015-10-07
{
"EventSourceName": "{{event_source_name}}",
"Name": "{{event_source_name}}"
}

Create a rule

Create a rule to route specified events to the event bus. Without a rule, all events are ignored.

Example query: Create a rule
POST https://events.{{regions}}.amazonaws.com/?Action=PutRule&Version=2015-10-07
{
"Description": "Default rule to route all bigcommerce events.",
"EventBusName": "{{event_source_name}}",
"EventPattern": "{\"detail-type\":[\"bigCommerceWebhook\"]}",
"Name": "{{rule_name}}",
"State": "ENABLED"
}

Apply a target to the rule

Add the target to the specified rule. This step lets Amazon SQS receive message requests so you can verify end-to-end delivery.

Example query: Put targets
POST https://events.{{regions}}.amazonaws.com/?Action=PutTargets&Version=2015-10-07
{
"EventBusName": "{{event_source_name}}",
"Rule": "{{rule_name}}",
"Targets": [
{
"Arn": "arn.aws:sqs:us-east-1:932486483912:{{sqs_name}}",
"Id": "{{sqs_id}}"
}
]
}

Create an Amazon EventBridge webhook

Create the webhook with the createEventBridgeWebhook mutation, using the event source ARN as the destination.

Example query: Create Amazon EventBridge webhook
POST https://{{zone}}/stores/{{store_hash}}/graphql
mutation createAwsEventBridgeWebhook($input: CreateEventBridgeWebhookInput!){
webhook {
createEventBridgeWebhook(input: $input) {
webhook {
id
scope
destination
isActive
createdAt
}
}
}
}
GraphQL variables
{
"input": {
"destination": "{{event_source_arn}}",
"isActive": true,
"scope": "store/category/updated"
}
}

Receive the event message

Trigger the event to receive the event message. Although the SQS API has limited JSON support, you can use SQS Receive Messages to view the event message.

For a complete reference of all BigCommerce webhook events and their callback payloads, see Webhook Events.

Troubleshooting

Field validation errors

To resolve a validation error, update the specified field to a valid value.

Internal validation errors

Retry the request after a short delay to resolve an internal error.

Articles

Endpoints