# WebsocketsApi logical id with invoke local

**URL:** <https://forum.serverless.com/t/websocketsapi-logical-id-with-invoke-local/15715>\
**Category:** Serverless Framework\
**Tags:** variables\
**Created:** [August 9, 2021, 2:30pm UTC](https://forum.serverless.com/t/websocketsapi-logical-id-with-invoke-local/15715 "2021-08-09T14:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldebout](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/aldebout/32/6077_2.png) [@aldebout](https://forum.serverless.com/u/aldebout)\
**Post date:** [August 9, 2021, 2:30pm UTC](https://forum.serverless.com/t/websocketsapi-logical-id-with-invoke-local/15715/1 "2021-08-09T14:30:00Z")

</div>

I use the API Gateway websockets and need to pass the connection url to my lambdas.

The WS resource is defined by having the event on a lambda (ts syntax):

```auto
events: [
    {
      websocket: {
        route: 'render',
      },
    },
  ],

```

I then reference it in the custom section to create a variable with the right id.

```auto
custom: {
    apiGatewayEndpoint: {
      'Fn::Sub':
        'https://${WebsocketsApi}.execute-api.${AWS::Region}.amazonaws.com/${self:provider.stage}',
    },
  },

```

This works well with `serverless deploy`, but when I try to `invoke local` any function, I get an error:

```auto
Could not resolve "apiGatewayEndpoint" environment variable: Unsupported environment variable format: {
    'Fn::Sub': 'https://${WebsocketsApi}.execute-api.${AWS::Region}.amazonaws.com/alexdb'
  }

```

What could be a way to have a fully dynamic serverless config file? I would like to avoid having to add local .env files with the ids for my dev stacks.

---

<div class="post-metadata">

**Author:** ![tbeauvais](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/tbeauvais/32/7907_2.png) [@tbeauvais](https://forum.serverless.com/u/tbeauvais)\
**Post date:** [May 20, 2024, 7:13pm UTC](https://forum.serverless.com/t/websocketsapi-logical-id-with-invoke-local/15715/2 "2024-05-20T19:13:06Z")

</div>

Howdy there, did you find a solution? I am having this exact problem.
