Hi, for websocket api authorizers there is wrong d...
# help
m
Hi, for websocket api authorizers there is wrong documentation I guess. I may did something wrong aswell. Can u please check I'm getting error AuthorizerResultTtlInSeconds cannot be set for WEBSOCKET protocol Apis. Documentation : https://docs.serverless-stack.com/constructs/WebSocketApi#adding-lambda-authorization
Copy code
this.wsAuthorizerFn = new sst.Function(this, "ws-authorizer", {
  handler: "src/services/messenger.wsAuthorizer",
})


this.messengerApi = new sst.WebSocketApi(this, "messenger-service", {
  accessLog: false,
  authorizationType: sst.WebSocketApiAuthorizationType.CUSTOM,
  authorizer: new HttpLambdaAuthorizer({
    authorizerName: `LambdaAuthorizer`,
    handler: this.wsAuthorizerFn
  }),
  routes: {
    $connect: {
      handler: "src/services/messenger.onWebsocketConnected",
      environment: {
        WEBSOCKET_CONNECTION_TABLE: this.connectionTable.tableName
      }
    },
    $disconnect: {
      handler: "src/services/messenger.onWebsocketDisconnected",
      environment: {
        WEBSOCKET_CONNECTION_TABLE: this.connectionTable.tableName
      }
    },
  }
})
failed: AuthorizerResultTtlInSeconds cannot be set for WEBSOCKET protocol Apis. (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: d46f8a9a-e138-4a00-8b9e-fc60c36e9da9; Proxy: null)
Also I found this https://docs.serverless-stack.com/constructs/WebSocketApi#authorizationtype It says Currently it only supports IAM.
f
Hey @Mehmet Ali SARAÇ, you are right, the doc is wrong. Both IAM and Custom Lambda authorizers are supported.
Just updated the doc.
Your code above looks right at glance. Did you get it to work?
I can give it a try on my end.
m
I coulnt find any solution. I created authorizer from console 🙂
h
I can confirm same issue here.
Copy code
AuthorizerResultTtlInSeconds cannot be set for WEBSOCKET protocol Apis. (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: 5a7ab438-c502-4494-a779-1e798b178382; Proxy: null)
With the same custom authorizer, I've been deploying it through SLS for the time being.
m
Any updates on this topic ? @Frank
f
Hey @Mehmet Ali SARAÇ, yeah I put a fix in last night https://github.com/serverless-stack/serverless-stack/issues/905
Will cut a release today
Released! Give v0.46.0 a try, let me know if it fixes the issue!