Skip to content

garysassano/cdk-aws-appsync-events

Repository files navigation

cdk-aws-appsync-events

CDK app that deploys an AppSync Event API with Lambda and DynamoDB data source integrations.

Prerequisites

Installation

npx projen install

Deployment

npx projen deploy

Usage

  1. Once deployed, test sending messages and subscribing to events in both namespaces:
    • In AWS Console, AppSyncsample-apiPub/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, CloudWatchLog groups/aws/lambda/sample-function.
  3. For the bar namespace:
    • To see the messages stored in the table:
      • In AWS Console, DynamoDBTablessample-table.

Cleanup

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

Architecture Diagram

About

CDK app that deploys an AppSync Event API with Lambda and DynamoDB data source integrations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published