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):
events: [
{
websocket: {
route: 'render',
},
},
],
I then reference it in the custom section to create a variable with the right id.
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:
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.