Deploy the APIs

Yes connecting to the Lambda function

I haven’t looked into it. So I don’t really know. But there might be some efforts that do something like that.

That worked for me too! Thanks for posting.

1 Like

getting below error when using serverless deploy

Serverless: Invoke deploy

  Type Error ---------------------------------------------

  TypeError: functionConfig.events.map is not a function
      at C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\lib\utils\analytics\generatePayload.js:52:39
      at Array.map (<anonymous>)
      at module.exports (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\lib\utils\analytics\generatePayload.js:50:52)
      at C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\lib\plugins\deploy\deploy.js:118:27
      at tryCatcher (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\util.js:16:23)
      at Function.Promise.attempt.Promise.try (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\method.js:39:29)
      at Object.before:deploy:deploy [as hook] (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\lib\plugins\deploy\deploy.js:102:22)
      at C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:483:55
      at tryCatcher (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\util.js:16:23)
      at Object.gotValue (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\reduce.js:168:18)
      at Object.gotAccum (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\reduce.js:155:25)
      at Object.tryCatcher (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\util.js:16:23)
      at Promise._settlePromiseFromHandler (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:547:31)
      at Promise._settlePromise (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:604:18)
      at Promise._settlePromiseCtx (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:641:10)
      at _drainQueueStep (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\async.js:97:12)
      at _drainQueue (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\async.js:86:9)
      at Async._drainQueues (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\Sharmaji\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\async.js:15:14)
      at processImmediate (internal/timers.js:439:21)
      at process.topLevelDomainCallback (domain.js:131:23)

This seems to be an issue with your serverless.yml. Make sure the events portion of your functions are indented properly, like this:

n trying to deploy the server, this is the problem I’m facing. All my functions are working individually when invoked locally.

$ serverless deploy

Serverless: DOTENV: Loading environment variables from .env:
Serverless: - STRIPE_SECRET_KEY
Serverless: Configuration warning:
Serverless: at ‘functions.update.events’: should be array
Serverless: at ‘functions.delete.events’: should be array
Serverless:
Serverless: If you prefer to not continue ensure “configValidationMode: error” in your config
Serverless: If errors are influenced by an external plugin, enquiry at plugin repository so schema extensions are added (h ttps://www.serverless.com/framework/docs/providers/aws/guide/plugins#extending-validation-schema)
Serverless: If errors seem invalid, please report at h ttps://github.com/serverless/serverless/issues/new?template=bug_report.md
Serverless: If you find this functionality problematic, you may turn it off with “configValidationMode: off” setting
Serverless:

Type Error ---------------------------------------------

The link to the GitHub repo: https://github.com/DjKesu/serverless-neat-notes-api

This is an issue with the serverless.yml. Compare it to the one from the guide:

YAML can be very finicky.

Got it working, Thank you!

I got error like this

An error occurred: IamRoleLambdaExecution - Syntax errors in policy. (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID: 0e1b3d2d-be5d-4b9a-a6b3-3ff67a148388; Proxy: null).

Hi, after running serverless deploy I get the following error:

Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayRestApi] in the Resources block of the template

Tried searching around, but couldn’t get what I needed. Please help!

EDIT: Sorry! It was a serverless.yaml indentation issue! I had to indent the path, method, cors and authorizer one step further in! :tired_face:

1 Like

Ughh yeah need to watch out for those!

@fathisiddiqi Can you post the complete log?

that error was solved

1 Like

man, that indentation is a killer! :scream: I had the same error. Thanks for your post. it helped me out. :slight_smile:

2 Likes

Hey All! I am new to serverless so please excuse if this is obvious but I am confused. I have the following two questions:

Ques 1:
After I run the command serverless deploy then when I go to the API Gateway console, there I see that in stages tab I still have the hello resource and also in Deployment History I only see the current deployment and not the previous one where I deployed only the hello API.

Ques 2:
After running serverless deploy how did Lambda function notes-api-prod-hello automatically got removed from my account because I dont see it in the Lambda console?

How did you solve it?

Serverless is creating a CloudFormation template that manages this internally. So it tells AWS that this stack has the resources that you defined. AWS will then add/remove them.

Hello! Thanks for this cool tuto :slight_smile: So after I ran serverlerss deploy, everything seems in order, but when I visit en endpoint, I have the following error:

  • error: “User: arn:aws:sts::088286864865:assumed-role/notes-api-prod-us-east-2-lambdaRole/notes-api-prod-get is not authorized to perform: dynamodb:GetItem on resource: arn:aws:dynamodb:us-east-2:088286864865:table/notes”

I tried double checking my IAM permissions, but everything seems fine. What can I do to solve this?

Here is my iamRoleStatements block:

 iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Scan
        - dynamodb:Query
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
        - dynamodb:DescribeTable
      Resource: "arn:aws:dynamodb:us-east-2:088286864865:table/notes
"

Hmm can you try playing around with the Resource part to make sure you are using the right format?