# Amazon Chime SDK Televisit Demo: Backend Infrastructure ### Prerequisites To deploy the serverless demo you will need: - Node 10 or higher - npm 6.11 or higher And install aws and sam command line tools: - [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv1.html) - [Install the AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) ### Run deployment script To build and deploy your application for the first time, run the following in your shell: ```bash sam build sam deploy --guided --capabilities CAPABILITY_NAMED_IAM ``` When you deploy the template for the first time, it will create an Amazon Chime App Instance through a Lambda function triggered by Custom Resource, so the parameter ChimeAppInstanceArn is not used. After the first deployment, the ARN of Chime App Instance will be returned by Lambda function if the execution is finished successfully, and it will be available in the Outputs of CFN stack. If the deployment suspends and waits for Custom Resource, please check the CloudWatch log of ChimeAppInstanceLambda function execution. The ChimeAppInstanceLambda function will use the parameter ChimeAppInstanceArn during the following updates of the same stack, so please provide the parameter ChimeAppInstanceArn from the first-time deployment when you update the same stack. It is Okay to create Lambda functions without authorization defined during the guided SAM deployment, since the authorization is controlled by Cognito authorized IAM role. So the first time guided deployment will look at this: ``` Setting default arguments for 'sam deploy' ========================================= Stack Name [sam-app]: AWS Region [us-east-1]: Parameter DemoName [ChimeSDKTelevisitDemo]: Parameter ChimeAppInstanceArn [arn:aws:chime:us-east-1::app-instance/]: #Shows you resources changes to be deployed and require a 'Y' to initiate deploy Confirm changes before deploy [y/N]: #SAM needs permission to be able to create roles to connect to the resources in your template Allow SAM CLI IAM role creation [Y/n]: CredApiFunction may not have authorization defined, Is this okay? [y/N]: Y CreateMeetingApiFunction may not have authorization defined, Is this okay? [y/N]: Y StartTranscriptionApiFunction may not have authorization defined, Is this okay? [y/N]: Y CreateAttendeeApiFunction may not have authorization defined, Is this okay? [y/N]: Y StartMeetingRecordingApiFunction may not have authorization defined, Is this okay? [y/N]: Y StopMeetingRecordingApiFunction may not have authorization defined, Is this okay? [y/N]: Y EndMeetingApiFunction may not have authorization defined, Is this okay? [y/N]: Y Save arguments to configuration file [Y/n]: SAM configuration file [samconfig.toml]: SAM configuration environment [default]: ``` The CFN stack has to be deployed in us-east-1 region for now since Amazon Chime SDK chat messaging is only available in us-east-1. This template will create several API Gateway endpoints handled by Lambda functions. Please check the CloudWatch logs for APIs and Lambda functions when things go wrong. Take notes of the CFN deployment Outputs that will be used in frontend stack deployment:

It is noteworthy that the CORS headers generated by Lambda functions have: ``` 'Access-Control-Allow-Origin': '*' ``` Please replace the wild card with env as the CloudFront distrubtion to limit the access.