This SAM application provides the Lambda functions, DynamoDB table, and roles to allow you to build a simple chat application based on API Gateway's new WebSocket-based API feature.
Clone or download
dgomesbr Merge pull request #7 from mpopp/stale-connection-deletion
Change deleteItem to delete, thanks for the catching that @mpopp
Latest commit c4a666b Jan 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Creating initial file from template Dec 17, 2018
onconnect Update to reflect final state. Dec 17, 2018
ondisconnect Update to reflect final state. Dec 17, 2018
sendmessage Change deleteItem to delete Jan 14, 2019
.gitignore Update to reflect final state. Dec 17, 2018
CODE_OF_CONDUCT.md initial import Dec 17, 2018
CONTRIBUTING.md initial import Dec 17, 2018
LICENSE Creating initial file from template Dec 17, 2018
README.md Update README.md Dec 18, 2018
template.yaml fixes #1 Dec 18, 2018

README.md

simple-websockets-chat-app

This is the code and template for the simple-websocket-chat-app. There are three functions contained within the directories and a SAM template that wires them up to a DynamoDB table and provides the minimal set of permissions needed to run the app:

.
├── README.md                   <-- This instructions file
├── onConnect                   <-- Source code onConnect
├── onDisconnect                <-- Source code onDisconnect
├── sendMessage                 <-- Source code sendMessage
└── template.yaml               <-- SAM template for Lambda Functions and DDB

Deploying to your account

You have two choices for how you can deploy this code.

Serverless Application Repository

The first and fastest way is to use AWS's Serverless Application Respository to directly deploy the components of this app into your account without needing to use any additional tools. You'll be able to review everything before it deploys to make sure you understand what will happen. Click through to see the application details.

AWS CLI commands

If you prefer, you can install the AWS SAM CLI and use it to package, deploy, and describe your application. These are the commands you'll need to use:

sam package \
    --template-file template.yaml \
    --output-template-file packaged.yaml \
    --s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME

sam deploy \
    --template-file packaged.yaml \
    --stack-name simple-websocket-chat-app \
    --capabilities CAPABILITY_IAM \
    --parameter-overrides MyParameterSample=MySampleValue

aws cloudformation describe-stacks \
    --stack-name simple-websocket-chat-app --query 'Stacks[].Outputs'

License Summary

This sample code is made available under a modified MIT license. See the LICENSE file.