https://github.com/garysassano/cdk-aws-appsync-events
CDK app that deploys an AppSync Event API with Lambda and DynamoDB data source integrations
https://github.com/garysassano/cdk-aws-appsync-events
appsync appsync-data-sources appsync-event-api appsync-events aws-appsync aws-cdk aws-lambda ddb dynamodb
Last synced: 9 months ago
JSON representation
CDK app that deploys an AppSync Event API with Lambda and DynamoDB data source integrations
- Host: GitHub
- URL: https://github.com/garysassano/cdk-aws-appsync-events
- Owner: garysassano
- License: apache-2.0
- Created: 2025-05-04T14:51:47.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-23T08:05:32.000Z (11 months ago)
- Last Synced: 2025-07-23T09:29:43.975Z (11 months ago)
- Topics: appsync, appsync-data-sources, appsync-event-api, appsync-events, aws-appsync, aws-cdk, aws-lambda, ddb, dynamodb
- Language: TypeScript
- Homepage:
- Size: 83 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cdk-aws-appsync-events
CDK app that deploys an AppSync Event API with Lambda and DynamoDB data source integrations.
## Prerequisites
- **_AWS:_**
- Must have authenticated with [Default Credentials](https://docs.aws.amazon.com/cdk/v2/guide/cli.html#cli_auth) in your local environment.
- Must have completed the [CDK bootstrapping](https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html) for the target AWS environment.
- **_Node.js + npm:_**
- Must be [installed](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) in your system.
## Installation
```sh
npx projen install
```
## Deployment
```sh
npx projen deploy
```
## Usage
1. 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**:
1. Select a namespace.
2. Provide a channel name (e.g., `/ch1`).
3. Leave the default JSON payload or provide a custom one.
4. Click `Publish`.
- To **subscribe to messages**:
1. Select a namespace.
2. Provide a channel name (e.g., `/ch1`) or leave the default (`/*`) to subscribe to all channels.
3. Click `Subscribe`.
2. For the `foo` namespace:
- 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`.
3. For the `bar` namespace:
- To see the messages stored in the table:
- In AWS Console, `DynamoDB` ➜ `Tables` ➜ `sample-table`.
## Cleanup
```sh
npx projen destroy
```
## Application Details
- `foo`
- An AppSync namespace with a Lambda data source integration.
- It uses a `Direct` handler for all events.
- Logs `onPublish` and `onSubscribe` events, while transforming `onPublish` messages.
- `bar`
- An AppSync namespace with a DynamoDB data source integration.
- It uses an `AppSyncJS` handler for all events.
- Stores `onPublish` messages and `onSubscribe` events in a DynamoDB table.
## Architecture Diagram
