Skip to content

The device demo showcases a minimal app that can run in various hardware environments.

License

Notifications You must be signed in to change notification settings

aws-samples/amazon-chime-sdk-js-device-demo

About

The device demo showcases a minimal app that can run in various hardware environments. It is comprised of two parts:

  1. Controller app - A small application that is responsible for sending actions to the room app, and listening for data from the Room to update its UI

  2. Room app - The application that handles the business logic. It listens for messages from the Controller and executes them. It may then send a response back to the Controller to update its state

Running the demos

To run the device application demo locally:

  1. Ensure you have AWS credentials configured in your ~/.aws folder for a role with a policy allowing chime:CreateMeeting, chime:DeleteMeeting, and chime:CreateAttendee.

  2. Build dependencies: npm run build

  3. Start the webpack server: npm run start:client

  4. In another terminal in the same directory, start the node server: npm run start:backend

  5. Open two tabs or two browser windows, navigate to https://localhost:3000/ and https://localhost:3000/controller

Deploying the serverless device demo

You can deploy any of the demo as self-contained serverless application. Note: deploying the serverless demo may incur extra charges in your AWS account.

Install aws and sam command line tools

Run deployment script

The following will create a CloudFormation stack containing a Lambda and API Gateway deployment that runs the device demo.

cd serverless
node ./deploy.js -r us-east-1 -b <my-bucket> -s <my-stack-name>

The script will create an S3 bucket and CloudFormation stack with Lambda and API Gateway resources required to run the demo. After the script finishes, it will output a URL that can be opened in a browser.

AWS IoT

AWS IoT service is integrated in the device demo using Cognito identity pool for authentication.

Set up AWS IoT

  1. Log into the AWS console with your AWS credentials and go to the AWS IoT Core console
  2. Follow the developer guide to create IoT thing:
  3. Follow the developer guide to create certificate, create and attach IoT policy to certiifcate, and attach the policy to the thing created in step 2.
  4. Select the IoT thing and click Interact. Note down the HTTPS endpoint and replace AWS_IOT_HTTP_ENDPOINT in IoTClient.tsx with it.

Set up Cognito identity pool

  1. Log into the AWS console with your AWS credentials and go to the Amazon Cognito console
  2. Choose Manage Identity Pools, and then choose Create new identity pool. Type a name for the identity pool and select Enable access to unauthenticated identities from the Unauthenticated identities collapsible section. Choose Create Pool and then Allow. Note down the Identity pool ID and replace COGNITO_IDENTITY_POOL_ID in IoTClient.tsx with it. It will look like the following:
us-east-1:abcd1234-ab12-cd34-ef56-abcdef123456
  1. Navigate to AWS IAM console to add permission to the Cognito Unauthenticated IAM role
  2. Choose Roles and click on the 'Cognito_[IDENTITY-POOL-NAME]Unauth_Role' created in step 2. Click on the Policy, choose Edit policy and click JSON tab, copy the following policy:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "mobileanalytics:PutEvents",
                "cognito-sync:*",
                "cognito-identity:*",
                "iot:*"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

Then click Review Policy and Save changes

Test message publish on IoT console

Navigate to the AWS IoT console and select Test, choose Subscribe to a topic, then type in 'iot/meeting/#' and hit Subscribe to topic. When join meeting, toggle video, toggle screen share, leave and end meeting, check the Test console print out the corresponding message.

Cleaning up

To avoid incurring future charges, please delete any resources in your account that you are not using such as files in Amazon S3, Amazon ECS and Amazon Lambda instances, AWS Cloud9 environment and Amazon API Gateway entries.

License

This project is licensed under the Apache-2.0 License.

Disclaimer: Deploying the Amazon Chime SDK demo applications contained in this repository will cause your AWS Account to be billed for services, including the Amazon Chime SDK, used by the application.

About

The device demo showcases a minimal app that can run in various hardware environments.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks