API Gateway for processing Benchling Events
The codebase is organized as follows:
lib/constants.ts
- Shared constants and configurationlib/types.ts
- TypeScript interfaces and typeslib/state-machine.ts
- AWS Step Functions workflow definitionlib/lambda/process-export.ts
- Lambda function for processing exports
This project implements a serverless webhook processor for Benchling events using AWS services:
- API Gateway receives webhook events
- Step Functions orchestrates the processing
- S3 stores event data and entry details
- SQS handles notifications
See lib/README.md for detailed architecture documentation.
Create a .env
file with the following content:
export CDK_DEFAULT_ACCOUNT=XXXXXXXXXXXX
export CDK_DEFAULT_REGION=us-west-2
export BUCKET_NAME=bucket-in-that-region
export PREFIX=test/benchling-webhook
export QUEUE_NAME=STACK_NAME-PackagerQueue-XXXXXXX
export QUEUE_URL=https://sqs.$CDK_DEFAULT_REGION.amazonaws.com/$CDK_DEFAULT_ACCOUNT/$QUEUE_NAME
source .env
npx cdk bootstrap aws://$CDK_DEFAULT_ACCOUNT/$CDK_DEFAULT_REGION
npx cdk deploy
- Create an App Manifest that subscribes to the desired events
- In Benchling, go to lower left Profile -> Feature Settings -> Developer Console
- Apps -> Create app -> From manifest
- Select Public
- Add app manifest
- Create
- Create Client Secret
- Copy
BENCHLING_CLIENT_ID
andBENCHLING_CLIENT_SECRET
to.env
- Go to Overview -> Webhook URL
- Click edit
- Paste in the API Gateway URL from cdk
- Save
- Go to Version History -> Install
- Click "View app in workspace"
- Click "Activate"
- Go to Profile -> Tenant Admin console
- Verify it is in Apps
- Go to Organizations -> "your org"
- Go to "Apps" tab
- Start typing 'package-with-quilt' in the search box
- Click "Add app"
- Select the app
- Change the 'Role' to 'Admin'
- Create a new entry in the Benchling app
- Go to the "Benchling" tab
- Click "Create > Entry -> Blank entry"
- Set a name
- Click "Create"
- Add the Canvas app to the entry
- Select "Insert -> Canvas" from the Toolbar
- Select "Quilt Integration"
- Click "Insert"
- In the Canvas section
- Click "Create" (wait a few seconds for it to create)
- Wait a bit for the package to be asynchronously created
- Command-Click "Quilt Catalog" to open the package in a new window
- Drag in an attachment to the Benchling entry
- Click "Update package" to create a new version
export ENDPOINT_ID=4abcdef123
export ENDPOINT_URL=https://$ENDPOINT_ID.execute-api.$CDK_DEFAULT_REGION.amazonaws.com/$STAGE/event
export ENTRY_ID=etr_XXXXXX
curl -X POST $ENDPOINT_URL -H "Content-Type: application/json" -d @test/entry-updated.json
aws s3 cp s3://$BUCKET_NAME/$PREFIX/$ENTRY_ID/api_payload.json -
open https://$QUILT_CATALOG/b/$BUCKET_NAME/tree/$PREFIX/$ENTRY_ID
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testsnpx cdk deploy
deploy this stack to your default AWS account/regionnpx cdk diff
compare deployed stack with current statenpx cdk synth
emits the synthesized CloudFormation template