CDK app that deploys an AppSync Event API with Lambda and DynamoDB data source integrations.
- AWS:
- Must have authenticated with Default Credentials in your local environment.
- Must have completed the CDK bootstrapping for the target AWS environment.
- Node.js + npm:
- Must be installed in your system.
npx projen installnpx projen deploy- Once deployed, test sending messages and subscribing to events in both namespaces:
- In AWS Console,
AppSync➜sample-api➜Pub/Sub Editor. - To send a message:
- Select a namespace.
- Provide a channel name (e.g.,
/ch1). - Leave the default JSON payload or provide a custom one.
- Click
Publish.
- To subscribe to messages:
- Select a namespace.
- Provide a channel name (e.g.,
/ch1) or leave the default (/*) to subscribe to all channels. - Click
Subscribe.
- In AWS Console,
- For the
foonamespace:- You should see that the messages received by subscribers are transformed.
- Optionally, to see the logs generated by the Lambda function:
- In AWS Console,
CloudWatch➜Log groups➜/aws/lambda/sample-function.
- In AWS Console,
- For the
barnamespace:- To see the messages stored in the table:
- In AWS Console,
DynamoDB➜Tables➜sample-table.
- In AWS Console,
- To see the messages stored in the table:
npx projen destroyfoo- An AppSync namespace with a Lambda data source integration.
- It uses a
Directhandler for all events. - Logs
onPublishandonSubscribeevents, while transformingonPublishmessages.
bar- An AppSync namespace with a DynamoDB data source integration.
- It uses an
AppSyncJShandler for all events. - Stores
onPublishmessages andonSubscribeevents in a DynamoDB table.