如何使用无服务器框架部署Websocket

时间:2020-05-26 04:37:52

标签: amazon-web-services serverless

我在serverless.yml上进行了以下配置。但是它没有部署websocket连接。我不知道我的配置有什么问题。我已遵循以下指示:https://www.serverless.com/framework/docs/providers/aws/events/websocket/

service:
  name: ${opt:componentName}-api

plugins:
  - '@hewmen/serverless-plugin-typescript'

provider:
  name: aws
  runtime: nodejs12.x
  region: ap-southeast-2
  websocketsApiName: custom-websockets-api-name
  websocketApiRouteSelectionExpression: $request.body.action

  stackName: ${opt:stage}-${self:service.name}
  iamRoleStatements:
      - Effect: Allow
        Action:
          - logs:Create*
          - logs:Get*
        Resource: "*"
      - Effect: Allow
        Action:
          - dynamodb:*
        Resource: "*"

functions:
  wsHandler:
    handler: src/websocketLambda.handleWebSocket
    name: ${self:provider.stackName}-ws
    evnets:
      - websocket: $default

serverless deploy的输出是:

Serverless: Stack update finished...
Service Information
service: device-api-transactions-api
stage: dev
region: ap-southeast-2
stack: dev-device-api-transactions-api
resources: 6
api keys:
  None
endpoints:
  None
functions:
  wsHandler: dev-device-api-transactions-api-ws
layers:
  None
Serverless: Removing old service artifacts from S3...
Serverless: Run the "serverless" command to setup monitoring, troubleshooting and testing.

0 个答案:

没有答案