Deploy the simple chat backend, create a new Amazon IVS channel using AWS CloudFormation, and retrieve everything you need to configure the demo.
- Access to AWS Account with permission to create IAM role, and Lambda.
- AWS CLI Version 2
- AWS SAM CLI
Before you start, run the following command to make sure you're in the correct AWS account (or configure as needed):
aws configure
For additional help on configuring, please see https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
- Replace
<my-bucket-name>
with your bucket name. - Replace
<my-region>
with your region name.
aws s3api create-bucket --bucket <my-bucket-name> --region <my-region> \
--create-bucket-configuration LocationConstraint=<my-region>
sam package \
--template-file template.yaml \
--output-template-file packaged.yaml \
--s3-bucket <my-bucket-name>
DO NOT run the output from above command, proceed to next step.
Replace <my-stack-name>
with your stack name.
sam deploy \
--template-file packaged.yaml \
--stack-name <my-stack-name> \
--capabilities CAPABILITY_IAM
On completion, save the following values:
WebSocketURI
, used in the demo configuration file (config.js
), to send/receive chat messagesChannelIngestEndpoint
, to be used in your broadcasting software (ex. OBS)StreamKey
, to be used in your broadcasting software (ex. OBS)ChannelPlaybackUrl
, used in the demo configuration file (config.js
), to load your Amazon IVS stream in the video player
If needed, to retrieve Cloudformation stack outputs again, run below command:
aws cloudformation describe-stacks --stack-name <my-stack-name>
aws cloudformation describe-stacks \
--stack-name <my-stack-name> --query 'Stacks[].Outputs'
To test the WebSocket API, you can use wscat, an open-source command line tool.
- Install NPM.
- Install wscat:
$ npm install -g wscat
- On the console, connect to your published API endpoint by executing the following command:
Replace <WebSocketURI>
with your WebSocketServer URL created when deploying with cloudformation.
$ wscat -c <WebSocketURI>
- To test the sendMessage function, send a JSON message like the following example. The Lambda function sends it back using the callback URL:
Replace <WebSocketURI>
with your WebSocketServer URL created when deploying with cloudformation.
$ wscat -c <WebSocketURI>
connected (press CTRL+C to quit)
> {"action":"sendmessage", "data":"hello world"}
< hello world
Follow the detailed instructions on how to get the frontend up and running.
- Delete Cloudformation stack:
aws cloudformation delete-stack --stack-name <my-stack-name>
- Remove files in S3 bucket
aws s3 rm s3://<my-bucket-name> --recursive
- Delete S3 bucket
aws s3api delete-bucket --bucket <my-bucket-name> --region <my-region>