Amazon EventBridge API Destinations to Stripe

EventBridge rule → Connection → API

Create an API destination in EventBridge for Stripe APIs.

This pattern configures an EventRule, that routes to the EventBridge API destination in EventBridge for Stripe to create a new product object API.
Once deployed, the pattern allows a user to send events easily through to create specific goods or services for supporting the product experience at Stripe. The pattern creates the following resources:
- EventBridge Event Bus
- EventBridge Rule
- EventBridge Connection
- EventBridge API Destination
- IAM Role
- SQS Queue
- SQS Queue Policy
The EventBridge Rule uses the API Destination and Connection as a target, SQS Queue as a Dead Letter Queue (DLQ), and the IAM role as its role. The created IAM role has the permission to allow InvokeApiDestination access to the EventBridge Rule.
If using the custom named IAM role in this pattern, it requires the explicit acknowledgement that the stack template contains certain capabilities in order for AWS CloudFormation to create the stack. When using the AWS SAM CLI, the --capabilities=CAPABILITY_NAMED_IAM parameter can be added to the deployment command to explicitly acknowledge.
To send events, go to the EventBridge Event Bus details. Select the Send events button. Select the Event Bus created by the pattern, "StripeEventBus". Enter "MyStripeTestApp" for the source. Enter "MyStripeTestAppDetailType" for the detail type. Enter Event details in json format for a creating a product (https://stripe.com/docs/api/products) API call.
The Stripe API uses API keys to authenticate requests (https://stripe.com/docs/api/authentication.) Before using the pattern, obtain an API Key from Stripe and update the CloudFormation template parameter "StripeAPIKeyValue" using Bearer auth.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/eventbridge-api-destinations

Deploy

cd ./10-stripesam deploy --guided


Testing

1. From a command line in this directory, send a test event to EventBridge simulating a "Payment failed" event: aws events put-events --entries file://testEvent.json

Cleanup

1. Delete the stack: sam delete --stack-name STACK_NAME.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"

Created by:

Diana Di Dow

Diana Di Dow

AWS Technical Account Manager

Follow on LinkedIn