Reference Websocket Api url in serverless.yml

api-gateway
aws
#1

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

0 Likes

#2

Hi, have you tried to use WebsocketsApi ?

0 Likes

Reference more than one api as variable/enviroment in serverless.yml
#3

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

0 Likes