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?

asked 3 years ago1654 views
1 Answer
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

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions