Websocket Authorizer Status 500

0

I have created an API Gateway Websocket with $connect and $disconnect and it works fine, I can connect and save the connectionId to Dynamodb. The problem appears when I add the authorizer in front of the $connect route using the console and following the steps and the output format in the Documentation, I got then always "error: Unexpected server response: 500", of course, I can see the logs of the Authorizer lambda and the return json which looks like following:

Region: eu-central-1

{
    "principalId": "me",
    "context": null,
    "usageIdentifierKey": "<API-ID>",
    "policyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": "execute-api:Invoke",
                "Resource": "arn:aws:execute-api:eu-central-1:<ACC-ID>:<API-ID>/Test/$connect",
                "Effect": "Allow"
            }
        ]
    }
}

So, after the authorizer function is invocked, the connection function is not called. has someone already faced this Problem and if yes, how did you solve it?

1개 답변
1

Hurrrrra, I have found it, I will add my Problem hier, may be it helps someone else. The Problem in case was the Trust relationships permssion that needs to be added to the role of the functions that you integrated with API Gateway. And how I found that, I have check the logs of the API not the functions, so you may find in the logs under CloudWatch => Logs => Log groups => (/aws/apigateway/<API-ID>/<Stage>), the following error:

(<ConnectionId>) Execution failed due to configuration error: API Gateway does not have permission to assume the provided role arn:aws:iam:<ACC-ID>:role/<Role-name>

Then go to the role it self and then to the trusted relationhsips and then edit this permission to have the api gateway like following:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "apigateway.amazonaws.com",
          "lambda.amazonaws.com"
        ]
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

I hope it will help someone else.

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인