AWSTemplateFormatVersion: "2010-09-09" Transform: "AWS::Serverless-2016-10-31" Description: Amazon IVS Simple Chat Backend Globals: Api: Cors: AllowMethods: "'GET,POST,OPTIONS'" AllowHeaders: "'*'" AllowOrigin: "'*'" Function: Runtime: nodejs18.x Timeout: 30 MemorySize: 128 Resources: IvsChatLambdaRefLayer: Type: AWS::Serverless::LayerVersion Properties: LayerName: sam-app-dependencies Description: Dependencies for sam app [ivs-simple-chat-backend] ContentUri: dependencies/ CompatibleRuntimes: - nodejs18.x LicenseInfo: "MIT" RetentionPolicy: Retain # This is a Lambda function config associated with the source code: chat-auth.js chatAuthFunction: Type: AWS::Serverless::Function Properties: Handler: src/chat-auth.chatAuthHandler Description: A function that generates an IVS chat authentication token based on the request parameters. Layers: - !Ref IvsChatLambdaRefLayer Policies: - Statement: Effect: Allow Action: - ivschat:* Resource: "*" Events: Api: Type: Api Properties: Path: /auth Method: POST # This is a Lambda function config associated with the source code: chat-event.js chatEventFunction: Type: AWS::Serverless::Function Properties: Handler: src/chat-event.chatEventHandler Description: A function that sends an event to a specified IVS chat room Layers: - !Ref IvsChatLambdaRefLayer Policies: - Statement: Effect: Allow Action: - ivschat:* Resource: "*" Events: Api: Type: Api Properties: Path: /event Method: POST # This is a Lambda function config associated with the source code: chat-event.js chatListFunction: Type: AWS::Serverless::Function Properties: Handler: src/chat-list.chatListHandler Description: A function that returns a list of available chat rooms Layers: - !Ref IvsChatLambdaRefLayer Policies: - Statement: Effect: Allow Action: - ivschat:* Resource: "*" Events: Api: Type: Api Properties: Path: /list Method: GET Outputs: ApiURL: Description: "API endpoint URL for Prod environment" Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"