red house 87
red house 87

Reputation: 2415

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?

Upvotes: 26

Views: 22044

Answers (5)

Pratik Kanade
Pratik Kanade

Reputation: 41

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.

Upvotes: 4

Tamojit Chakraborty
Tamojit Chakraborty

Reputation: 127

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

Upvotes: 11

live-love
live-love

Reputation: 52366

Check your region filter on the menu at the top of the AWS console.

Make sure it's the same as the region you deploy to in serverless.yml:

provider:
  name: aws
  runtime: nodejs12.x
  region: us-east-1

enter image description here

Upvotes: 1

victorvartan
victorvartan

Reputation: 1002

I had the same issue. Can't recall if it was because I changed the function name or because I added

  apiGateway:
    shouldStartNameWithService: true

to serverless.yml in the provider section. (I did this because I wanted to switch to the new API gateway naming)

Serverless was still tracking the old name, so in order to reset this and be able to deploy again I did these 3 steps:

  1. deleted the bucket that Serverless created in S3;
  2. deleted the stack that Serverless created in CloudFormation;
  3. deleted the .serverless folder that Serverless created in my project's root folder.

After that, the serverless deploy command worked again.

Upvotes: 0

hephalump
hephalump

Reputation: 6164

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.

Upvotes: 60

Related Questions