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

How to deploy a single function without deploying other functions on the api using serverless framework #4269

Closed
Erandakuruneru opened this issue Sep 15, 2017 · 16 comments

Comments

@Erandakuruneru
Copy link

The function "get-relationships" you want to update is not yet deployed. Please run "serverless deploy" to deploy your service. After that you can re
deploy your services functions with the "serverless deploy function" command.

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless

Your Environment Information -----------------------------
OS: win32
Node Version: 8.4.0
Serverless Version: 1.22.0

@HyperBrain
Copy link
Member

@Erandakuruneru That's not possible, as deploy function only deploys the new function code to an existing function. With Serverless your service including all functions is controlled by CloudFormation and the CloudFormation stack is set up, when you do a serverless deploy.

The deploy function mechanism is only a lightweight metod to just upload a function's code and replace it within AWS Lambda. But, special care has to be taken and deploy function should not be used for production deployments, because the deployed function code is completely outside of CloudFormation control. Whenever CF decides to to a stack update, rollback or correction, your code will be lost and reverted to the last full deployment -> The deployed CF template is not changed by deploying a single function that way!

In general, deploy function is currently a debug helper, to get functions deployed quickly without the need to deploy the whole service. In production environments this should never be used, because you'll end up with deployments uncontrolled by CF which is most likely not what you want on production.

@Erandakuruneru
Copy link
Author

Is there any way we can deploy the single function in service. Because we have special requirement to deploy new function rather than deploying all the functions to the service

@wenderjean
Copy link

@Erandakuruneru You can perform a sls deploy function yourfunctionname but the point is, you can only do that after an initial full deploy.

@pmuens
Copy link
Contributor

pmuens commented Sep 15, 2017

Thanks for opening @Erandakuruneru and thanks for the comments @HyperBrain and @wenderjean 👍

Yes, that's correct. The Serverless Framework AWS integration is based upon CloudFormation so you need to have a stack with functions in place to update functions via direct code pushes to Lambda (the Serverless deploy function command pushed the code and config update directly to Lambda via the AWS SDK without going through CloudFormation).

I hope that helps.

Closing this one since using this w/o an initial deploy is currently not possible.

@pmuens pmuens closed this as completed Sep 15, 2017
@dfloresgonz
Copy link

dfloresgonz commented May 31, 2018

I have three functions function1, function2 and functionUtil both function1 and 2 invoke funcitonUtil. Is there a way to change functionUtil and the change to take effect on both function1 and 2 without having to deploy function1 and 2 individually?

Note: functionUtil is not deployed as a unit it only exists inside so other functions can invoke it. it doesn't get invoked from the outside only internally.

@mrdulin
Copy link

mrdulin commented Apr 1, 2019

same issue. How to deploy a single cloud function in GCP without removing other cloud functions?

sls deploy -f <functionName> does not work.

@yogesh-ezest
Copy link

@Erandakuruneru Do you get any solution for this issue?

@Erandakuruneru
Copy link
Author

Still could not find the solution,
now we are deploying the multiples functions,which functions are related to the one module.

@nikhilbhalwankar
Copy link

nikhilbhalwankar commented Sep 13, 2019

Facing the same issue. I have 10 lambda functions under serverless. If I update one more lambda function in serverless.yml, all 11 functions are to be deployed. Takes a long time to deploy all.

@exoego
Copy link
Contributor

exoego commented Sep 13, 2019

Updating single function is already possible if provider is AWS, so this issue had been closed.

If you need same feature in other providers, I think opening a separate issue is good since we can track issue for each providers.

@yogesh-ezest
Copy link

@nikhilbhalwankar You can achieve using this by create separate .yaml file for each function. While deploying specific function, you can pass this respective .yaml file of function to the command "sls deploy function -f <function_name> --config <'.yaml file path'>"

@nikhilbhalwankar
Copy link

nikhilbhalwankar commented Sep 13, 2019

@nikhilbhalwankar You can achieve using this by create separate .yaml file for each function. While deploying specific function, you can pass this respective .yaml file of function to the command "sls deploy function -f <function_name> --config <'.yaml file path'>"

Thanks for this. Very helpful. However, I have one custom authorizer function for all 10 functions. How can I handle such case?

@yogesh-ezest
Copy link

@nikhilbhalwankar The custom authorizer is lambda function or normal python function, if it's normal function then you don't require to make it is lambda as well as .yaml file. You can just import this function in your lambda function file for your purpose.

@stiofand
Copy link

stiofand commented Nov 9, 2020

I can confirm sls deploy -f does not work on 2,8.0, it ends up deploying all functions even when an initial deploy has been done (with aws provider) it also zips them into one zip file so the upload limit is reached before it can deploy

@Satyam8891
Copy link

Maybe I am doing something wrong because while deploying python lambda, it zip all the code and deployed for all the lambdas.
Example- let's suppose I have 3 lambda A, B and C. first time I have to deploy all together that's fine but when I check on aws console then every lambda has all the code that means A has handler functions those are specific for b and c lambda..
even for each lambda I have separate file

@mata998
Copy link

mata998 commented Oct 10, 2023

Maybe I am doing something wrong because while deploying python lambda, it zip all the code and deployed for all the lambdas. Example- let's suppose I have 3 lambda A, B and C. first time I have to deploy all together that's fine but when I check on aws console then every lambda has all the code that means A has handler functions those are specific for b and c lambda.. even for each lambda I have separate file

@Satyam8891 Same here, can't find a way do deploy just one file to one lambda, always the whole code is deployed

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