Reference Websocket Api url in serverless.yml

Hello,
i’m trying to reference the api url of a websocket api.
I managed to get the reference of a api-gateway via Ref: “ApiGatewayRestApi”

I’m trying now to figure out the same method for a websocket api:

functions:
    apiWebsocket:
        handler: index.handler
        environment:
            WS_ENDPOINT: {Ref: "???????"}
        package:
        include:
            - src/**/*
        events:
        - websocket: $connect
        - websocket: $disconnect
        - websocket: $default

how can i do this?

there is something similar to how I did for the sqs queue?

sqsTest:
    handler: sqs/index.handler
    package:
    include:
        - sqs/**/*
    events:
    - sqs:
        arn:
            Fn::GetAtt:
            - sqsQueue
            - Arn

thank you very much

Hi, have you tried to use WebsocketsApi ?

Thank you very much, this is exactly what i needed!

1 Like