0
votes

I am getting below error when trying to deploy Express NodeJS application to AWS Lambda.

ServerlessError: Forbidden
      at /Users/name/.nvm/versions/node/v12.16.3/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:331:27
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

The command that detected the issue was SLS_DEBUG=1 serverless deploy

serverless.yml

service: mail-server
provider:
  name: aws
  runtime: nodejs12.16
  stage: dev
  region: ap-southeast-1
  memorySize: 128
functions:
  app:
    handler: app/app.handler
    events: 
      - http: 
          path: /
          method: ANY
          cors: true
      - http: 
          path: /{proxy+}
          method: ANY
          cors: true

I have been following this tutorial: https://bitbucket.org/blog/deploy-an-express-js-app-to-aws-lambda-using-the-serverless-framework

Below are the policy assigned:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1482712489000",
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole",
        "iam:PutRolePolicy",
        "lambda:CreateFunction",
        "lambda:InvokeAsync",
        "lambda:InvokeFunction",
        "iam:PassRole",
        "lambda:UpdateAlias",
        "lambda:CreateAlias",
        "lambda:GetFunctionConfiguration",
        "lambda:AddPermission",
        "lambda:UpdateFunctionCode",
        "s3:ListBucket"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

enter image description here

1
That looks like a local O/S error, not anything in Lambda. Does that file and parent directories exist on local file system and, if so, what are the permissions? - stdunbar

1 Answers

0
votes
  1. Try to check your code first if it requires any Env variables pass them to the function.
  2. Try to run your function on full admin access check if it works or not(Not a good idea but best to debug the permissions issue)

{ "Version": "2012-10-17", "Statement": [ { "Action": "*", "Resource": "*", "Effect": "Allow" } ] }

3: Try of dive more into logs from cloud watch.