WebSocket handshake: Unexpected response code: 403

0

Hi there!

I am having problems connecting to a websockets API created with Terraform.

In order to create it I did the following:

  1. I used Serverless to create a websockets API. Serverless example Websockets API works perfectly.
  2. Then I took the generated Cloudformation and I used the aws_cloudformation_stack resource in Terraform to create the API.

Lambda functions are created using Terraform and instead of including the whole cloudformation template copied and adapted from Serverless, I have removed the Cloudformation lambda related resources and I used the ARN generated by Terraform, passed via parameters.

The thing is, side by side, both APIs look exactly the same. Navigating the AWS UI all routes are created fine and the lambda functions are integrated correctly (apparently)

I can also execute the lambda functions independently and the console.logs are correctly written in the cloudwatch.

The problem is that when I try to connect to the Serverless API it works perfectly, but the Terraform API I receive a WebSocket handshake: Unexpected response code: 403

Any suggestions?

已提問 3 年前檢視次數 1687 次
1 個回答
0

Ok, I found out terraform / cloudformation template was not creating any deployment stage and therefore $routes were not connecting with the lambdas.

Notice that if you had a previous stage with the same name, you won't see the error.

I still didn't found how to create them using terraform. cloudformation, but if I create it manually the error disappears.

Thanks!

Edited by: XaviColomer on Nov 10, 2020 3:22 AM

已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南