codename_47
codename_47

Reputation: 449

Cannot deploy Node.js app inside AWS Lambda using Serverless Framework

I am new to serverless framework. I was trying to deploy my code to lambda using serverless.

service:
  name: store-consumer

provider: 
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: ap-XXXXXX-1

functions:
  lambda:
    handler: index.handler

The content of the serverless.yml file is as given above. But when I hit 'sls deploy' in terminal my code is zipped and uploaded to an s3 bucket. How do I deploy my code to the corresponding lambda using serverless?

I assume I 'll have to give some credentials for the lambda, but how do I do that in the .yml file?! What am I not getting correctly?

Upvotes: 0

Views: 546

Answers (1)

teyzer
teyzer

Reputation: 1618

You can specify the Lambda function name explicitly using the name field. Example:

service:
  name: store-consumer

provider: 
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: ap-XXXXXX-1

functions:
  lambda:
    handler: index.handler
    name: myfunc

With this config file your deployed Lambda function will have the name myfunc.

See line 129 in https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/.

Using the name of an already existing Lambda function will not work, you still have to delete old the Lambda function beforehand.

Upvotes: 0

Related Questions