Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define role for both Http and websocket API in one serverlss.yml #5886

Open
ankurgupta22 opened this issue Mar 1, 2019 · 3 comments
Open

Comments

@ankurgupta22
Copy link

Hi Team,

I am using AWS Websocket API with serverless framework 1.38.0 and I want to deploy both http and websocket event lamda with single serverless.yml and all lambda would share same existing IAM role. Hence for this I have declared role arn in provider tab but when I run sls deploy -v it says error - cannot read properties undefined.

My understanding is we can only define role arn at function level only either for event type http or wss or vice versa but if we defined role at both places it says same error as above.

Please help me how to define EXISTING role for both API’s either at global level or function level, sample YAML configuration will really help.

hello:
handler: CsharpHandlers::AwsDotnetCsharp.Handler::Hello
name: APITypeHello
#role: cant define role here hence it is being deployed with default role.
events:
- http:
path: api/shipments
method: post
cors: true
onConnect:
handler: CsharpHandlers::AwsDotnetCsharp.WSSConnectHandler::WSSConnect
role: arn:aws:iam::019095984934:role/lambdarolenew
name: onConnect
events:
- websocket:
route: $connect
- websocket:
route: $disconnect
chatMessage:
handler: CsharpHandlers::AwsDotnetCsharp.WebsocketHandler::GetWSSRequest
role: arn:aws:iam::019095984934:role/lambdarolenew
name: chatMessage
events:
- websocket:
route: chatMessage

Thanks
Ankur

@blackc0d3
Copy link

+1
I'm trying to do the same (defining an https event and a websocket).

In my case, the error i get is this:
..................................
Serverless: Stack update finished...
Serverless: Uploading CloudFormation alias file to S3...
Serverless: Updating alias stack...
Serverless Error ---------------------------------------
[/Resources/DefaultHandlerLambdaPermissionWebsockets/DependsOn/0] 'null' values are not allowed in templates

@castellanprime
Copy link

@blackc0d3 Are you defining both an https event and a websocket on a single route?

@blackc0d3
Copy link

blackc0d3 commented Mar 8, 2019

@castellanprime I'm not sure what you mean with same route. I've defined them as different functions... the websocket with a $default route and the https with its own path. Each of them invoke a method in the handler file.

For clarity:
..
functions:
websocketFunc:
handler: handler.wsMethod
events:
- websocket:
route: $default

otherFunc:
handler: handler.otherFuncMethod
events:
- http:
method: POST
path: /the/path
integration: lambda
..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants