Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless deploy - Function not found - sls deploy

I am trying to deploy a Serverless function via the Serverless CLI and I am getting the following error:

An error occurred: GenerateDownloadLinkLambdaFunction - Function not found:

What's strange is that I've deployed this function for another stage qa and it deployed fine, but for dev it just throws the above error.

If I try to manually create the function from the AWS console and deploy it, the Lambda functions menu shows that the function was deployed X seconds ago, however it does not show any of the settings I have in my serverless.yml file on my machine.

It's also worth noting that I had managed to have this function deployed on the dev stage but I accidentally deleted it. Since then it refuses to redeploy.

Have been banging my head against the wall as to what I'm doing wrong but can't spot anything, has anyone else encountered a similar issue with Serverless before?

like image 267
red house 87 Avatar asked Oct 14 '19 19:10

red house 87


People also ask

What is SLS deploy?

The sls deploy command deploys your entire service via CloudFormation. Run this command when you have made infrastructure changes (i.e., you edited serverless. yml ).

Which command is used to call the function in Serverless Framework SLS invoke?

Invokes a deployed function. You can send event data, read logs and display other important information of the function invocation.

What is AWS SLS?

sls-dev-tools is an open source project that aims to be a set of developer tools for the serverless world. Basing the interface in the terminal allows it to run in the development environment. It provides: Rapid in-terminal feedback—no need to use the AWS Management Console.


3 Answers

I’ve faced this issue with Serverless. The issue is caused by how Serverless handles, tracks, and deploys your functions. When you deleted the function you effectively changed the state of your application manually, and it is effectively out of sync.

To resolve this, comment out the function that is refusing to deploy, and run sls deploy. When its finished uncomment the function, and sls deploy again. This time it should deploy your function.

like image 102
hephalump Avatar answered Oct 06 '22 13:10

hephalump


Use sls remove to remove everything from the stack and then run sls deploy

like image 9
Tamojit Chakraborty Avatar answered Oct 06 '22 12:10

Tamojit Chakraborty


Caution: This will delete and recreate the whole stack including Databases if you have any, so try at your own risk

Use following command:

serverless remove --stage "environment" --region "region"

eg. serverless remove --stage dev --region us-east-1

The point is if you accidently/manually delete anything from the stack then you break the stack. You have to remove it in with above command and clean it up.

Another workaround would be to recreate the deleted component manually but again I suggest go with the above flow and now to break it.

like image 3
Pratik Kanade Avatar answered Oct 06 '22 11:10

Pratik Kanade