Skip to content

Test lambda that has websocket routes #25

Closed
@diegosasw

Description

@diegosasw

Not sure if it's possible with this approach, but suppose the lambda is the back-end for an API Gateway that uses websockets. How could this be tested using this interface emulator?

I haven't been able to find details on how an event to invoke a lambda function looks like when using web sockets.

I know for a REST Api this is a valid event

{
  "resource": "/{proxy+}",
  "path": "/api/values",
  "httpMethod": "GET",
  "headers": null,
  "queryStringParameters": null,
  "pathParameters": {
    "proxy": "api/values"
  },
  "stageVariables": null,
  "requestContext": {
    "accountId": "AAAAAAAAAAAA",
    "resourceId": "5agfss",
    "stage": "test-invoke-stage",
    "requestId": "test-invoke-request",
    "identity": {
      "cognitoIdentityPoolId": null,
      "accountId": "AAAAAAAAAAAA",
      "cognitoIdentityId": null,
      "caller": "BBBBBBBBBBBB",
      "apiKey": "test-invoke-api-key",
      "sourceIp": "test-invoke-source-ip",
      "cognitoAuthenticationType": null,
      "cognitoAuthenticationProvider": null,
      "userArn": "arn:aws:iam::AAAAAAAAAAAA:root",
      "userAgent": "Apache-HttpClient/4.5.x (Java/1.8.0_102)",
      "user": "AAAAAAAAAAAA"
    },
    "resourcePath": "/{proxy+}",
    "httpMethod": "GET",
    "apiId": "t2yh6sjnmk"
  },
  "body": null
}

and therefore, if I save it in a test_request.json I could test the lambda function like this with CURL when running in the emulator

curl -vX POST http://localhost:9000/2015-03-31/functions/function/invocations -d @test_request.json --header "Content-Type: application/json"

Is there anything similar when the event represents a $connect, $disconnect or sendmessage message from Api Gateway websocket to lambda?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions