SHARE
TWEET

Untitled

a guest Oct 13th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. service: awswebsocketchat
  2. frameworkVersion: "1.48.2"
  3.  
  4. custom:
  5.   currentStage: ${opt:stage, self:provider.stage}
  6.   lambdaRunTime: python3.7
  7.   socketConnectionsTableName: socketConnections-#{AWS::AccountId}-${self:custom.currentStage}
  8.  
  9. provider:
  10.   name: aws
  11.   iamManagedPolicies:
  12.   - arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess
  13.   runtime: ${self:custom.lambdaRunTime}
  14.   versionFunctions: false
  15.   region: eu-west-1
  16.   timeout: 29
  17.  
  18. plugins:
  19.   - serverless-pseudo-parameters
  20.  
  21. package:
  22.   individually: true
  23.   exclude:
  24.     - "lib/**"
  25.     - "node_modules/**"
  26.  
  27. layers:
  28.   pythonPackageLayer:
  29.     path: lib
  30.     name: Python-Package-layer
  31.     description: Python Package layer
  32.     compatibleRuntimes:
  33.       - ${self:custom.lambdaRunTime}
  34.  
  35. functions:
  36.   connectHandler:
  37.     handler: connect_handler.handle
  38.     events:
  39.       - websocket: $connect
  40.     layers:
  41.       - { Ref: PythonPackageLayerLambdaLayer }
  42.     environment:
  43.       SOCKET_CONNECTIONS_TABLE_NAME: ${self:custom.socketConnectionsTableName}
  44.  
  45.   disconnectHandler:
  46.     handler: disconnect_handler.handle
  47.     events:
  48.       - websocket: $disconnect
  49.     layers:
  50.       - { Ref: PythonPackageLayerLambdaLayer }
  51.     environment:
  52.       SOCKET_CONNECTIONS_TABLE_NAME: ${self:custom.socketConnectionsTableName}
  53.  
  54.   onMessageHandler:
  55.     handler: on_message_handler.handle
  56.     events:
  57.       - websocket:
  58.           route: onMessage
  59.     layers:
  60.       - { Ref: PythonPackageLayerLambdaLayer }
  61.     environment:
  62.       SOCKET_CONNECTIONS_TABLE_NAME: ${self:custom.socketConnectionsTableName}
  63.  
  64. resources:
  65.   Resources:
  66.     socketConnectionsTable:
  67.       Type: AWS::DynamoDB::Table
  68.       DeletionPolicy: Retain
  69.       Properties:
  70.         TableName: ${self:custom.socketConnectionsTableName}
  71.         AttributeDefinitions:
  72.           - AttributeName: connectionId
  73.             AttributeType: S
  74.         KeySchema:
  75.           - AttributeName: connectionId
  76.             KeyType: HASH
  77.         BillingMode: PAY_PER_REQUEST
  78.         SSESpecification:
  79.           SSEEnabled: true
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top