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?

preguntada hace 3 años1687 visualizaciones
1 Respuesta
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

respondido hace 3 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas