Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 error on running serverless invoke local #5

Open
quantuminformation opened this issue Sep 22, 2017 · 14 comments
Open

500 error on running serverless invoke local #5

quantuminformation opened this issue Sep 22, 2017 · 14 comments

Comments

@quantuminformation
Copy link

quantuminformation commented Sep 22, 2017

When running

$ serverless invoke local --function create --path mocks/create-event.json
from
https://serverless-stack.com/chapters/add-a-create-note-api.html

I get

{
    "statusCode": 500,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    },
    "body": "{\"status\":false}"
}

I added a log and get:
{ UnrecognizedClientException: The security token included in the request is invalid.

@jayair
Copy link
Member

jayair commented Sep 22, 2017

@quantuminformation Are you using multiple AWS credentials? Or do you have multiple credentials? This usually happens in that case.

@quantuminformation
Copy link
Author

quantuminformation commented Sep 22, 2017

Yeah I have 2 profiles:

same error even with --profile personal

serverless-stack-demo-api git:(master) ✗ serverless invoke local --function create --path mocks/create-event.json --profile personal 
Serverless: Bundling with Webpack...
Time: 641ms
    Asset     Size  Chunks             Chunk Names
create.js  7.19 kB       0  [emitted]  create
   [0] ./create.js 2.81 kB {0} [built]
   [1] external "babel-runtime/regenerator" 42 bytes {0} [not cacheable]
   [2] external "babel-runtime/helpers/asyncToGenerator" 42 bytes {0} [not cacheable]
   [3] external "uuid" 42 bytes {0} [not cacheable]
   [4] ./libs/dynamodb-lib.js 485 bytes {0} [built]
   [5] external "aws-sdk" 42 bytes {0} [not cacheable]
   [6] ./libs/response-lib.js 721 bytes {0} [built]
   [7] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
{ UnrecognizedClientException: The security token included in the request is invalid.

@jayair
Copy link
Member

jayair commented Sep 22, 2017

@quantuminformation The serverless invoke local command does not support the --profile option.

Did you specify the profile in your serverless.yml?

@quantuminformation
Copy link
Author

quantuminformation commented Sep 25, 2017

Yup , get same error:

   [7] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
{ UnrecognizedClientException: The security token included in the request is invalid.
provider:
  name: aws
  runtime: nodejs6.10
  stage: prod
  region: eu-west-2
  profile: personal

and in ~/.aws/credentials:

[personal]
aws_access_key_id

for some reasons image uploads dont work

@jayair
Copy link
Member

jayair commented Sep 25, 2017

@quantuminformation Do these credentials have access to the DynamoDB that was previously created?

@quantuminformation
Copy link
Author

[ Personal ] IAM user has the admin policy on this account.

Does invoke local do anything to the live AWS account and data?

@jayair
Copy link
Member

jayair commented Sep 25, 2017

@quantuminformation It invokes your Lambda function locally but any resources used inside it are the ones on live.

@quantuminformation
Copy link
Author

I'm going to test the react app against the api, sls deploy worked

@luanau
Copy link

luanau commented Oct 14, 2017

Had this same problem. Changed region to my real ones in serverless.yml and create.js

@dougharling
Copy link

dougharling commented Nov 1, 2017

I also am seeing this error or something very similar. I tried to go ahead and deploy the serverless package and got the same error with Webpack. I'll keep digging, but wanted to post the issue I'm seeing.

[11:08:10]dcharling@us-c02tf23vg8wn:~/Personal/dev/scratch> serverless invoke local --function create --path mocks/create-event.json
Serverless: Bundling with Webpack...
Time: 604ms
          Asset  Size  Chunks             Chunk Names
notes/create.js  5 kB       0  [emitted]  notes/create
   [0] ./notes/create.js 2.16 kB {0} [built]
   [1] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
   [2] external "uuid" 42 bytes {0} [not cacheable]
   [3] external "aws-sdk" 42 bytes {0} [not cacheable]
{
    "statusCode": 500,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    },
    "body": "{\"status\":false}"
}

@jayair
Copy link
Member

jayair commented Nov 1, 2017

@dougharling You can debug these by adding a console.log like so - https://serverless-stack.com/chapters/add-a-create-note-api.html#common-issues

@enriqueheyhey
Copy link

  1. click on your username on top nav, My Security Credentials
  2. Click on Access Key Tab, Create New, copy the key and secret.
  3. in terminal, run $ aws configure and use the new key and secret.
  4. Run the command again: serverless invoke local --function create --path mocks/create-event.json

@iamsaurabhc
Copy link

Yup , get same error:

   [7] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
{ UnrecognizedClientException: The security token included in the request is invalid.
provider:
  name: aws
  runtime: nodejs6.10
  stage: prod
  region: eu-west-2
  profile: personal

and in ~/.aws/credentials:

[personal]
aws_access_key_id

for some reasons image uploads dont work

Found the following steps to be the solution to the exact problem -

  1. Remove the current aws config and credentials by : sudo rm ~/.aws/config and sudo rm ~/.aws/credentials
  2. Recreate an access key for the User, from the IAM Console
  3. Reconfigure your AWS CLI with aws configure and make sure you put the correct region

Worked for me!

@mmjosedaniel
Copy link

mmjosedaniel commented Jul 7, 2020

I had this error. It was because I forgot to create the table in DynamoDB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants