From @jayair on Mon Apr 10 2017 00:59:33 GMT+0000 (UTC)
Link to chapter - http://serverless-stack.com/chapters/add-a-create-note-api.html
Copied from original issue: https://github.com/AnomalyInnovations/serverless-stack-com/issues/23
From @nerdguru on Mon Apr 10 2017 15:01:59 GMT+0000 (UTC)
The runtime line in the serverless.yml file should read:
runtime: nodejs6.10
Looks like you updated it for the prior page for Serverless 1.10ās support of AWS/Node6 but missed this one. Minor thing but thought youād want to know.
From @jayair on Mon Apr 10 2017 17:03:25 GMT+0000 (UTC)
Oh yeah youāre right. Just fixed it - 87587868b0829ded83cfde2a00e7a5af8f441518
From @geirman on Fri Apr 14 2017 23:48:42 GMT+0000 (UTC)
When testing the code, Iām getting a 500 response. How do I troubleshoot this?
The only thing Iāve done differently is change all instances of us-east-1
to us-east-2
to match values I see in my pool id, pool arn, identity pool id, etc. Seemed like the right thing to do.
From @jayair on Sat Apr 15 2017 00:00:02 GMT+0000 (UTC)
@geirman that would be a DynamoDB related error. Can you try printing out the error object in this line - https://github.com/AnomalyInnovations/serverless-stack-com/blame/master/_chapters/add-a-create-note-api.md#L56
That should give you a clue.
From @geirman on Sat Apr 15 2017 05:17:05 GMT+0000 (UTC)
Thanks, that helped. My problem was naming one of the keys notesId
instead of noteId
ValidationException: One or more parameter values were invalid: Missing the key notesId in the item
From @flocve on Mon Apr 17 2017 10:09:21 GMT+0000 (UTC)
Hello,
When I run the command : serverless webpack invoke --function create --path event.json
I have this :
{ statusCode: 500,
headers:
{ 'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true },
body: '{"status":false}' }
content of DynamoDB object :
Config {
credentials: null,
credentialProvider: [Object],
region: 'eu-west-2',
logger: null,
apiVersions: {},
apiVersion: null,
endpoint: 'dynamodb.eu-west-2.amazonaws.com',
httpOptions: [Object],
maxRetries: undefined,
maxRedirects: 10,
paramValidation: true,
sslEnabled: true,
s3ForcePathStyle: false,
s3BucketEndpoint: false,
s3DisableBodySigning: true,
computeChecksums: true,
convertResponseTypes: true,
correctClockSkew: false,
customUserAgent: null,
dynamoDbCrc32: true,
systemClockOffset: 0,
signatureVersion: 'v4',
signatureCache: true,
retryDelayOptions: {},
useAccelerateEndpoint: false },
isGlobalEndpoint: false,
endpoint:
Endpoint {
protocol: 'https:',
host: 'dynamodb.eu-west-2.amazonaws.com',
port: 443,
hostname: 'dynamodb.eu-west-2.amazonaws.com',
pathname: '/',
path: '/',
href: 'https://dynamodb.eu-west-2.amazonaws.com/' },
_clientId: 1 },
attrValue: 'S8' }
And the error is :
CredentialsError: Missing credentials in config
at ClientRequest.<anonymous> (/Users/flocve/Sites/labs/notes-app-api/node_modules/aws-sdk/lib/http/node.js:83:34)
at ClientRequest.g (events.js:291:16)
at emitNone (events.js:86:13)
at ClientRequest.emit (events.js:185:7)
at Socket.emitTimeout (_http_client.js:620:10)
at Socket.g (events.js:291:16)
at emitNone (events.js:86:13)
at Socket.emit (events.js:185:7)
at Socket._onTimeout (net.js:339:8)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
message: 'Missing credentials in config',
code: 'CredentialsError',
time: 2017-04-17T10:06:21.387Z,
retryable: true,
originalError:
{ message: 'Could not load credentials from any providers',
code: 'CredentialsError',
time: 2017-04-17T10:06:21.387Z,
retryable: true,
originalError:
{ message: 'Connection timed out after 1000ms',
code: 'TimeoutError',
time: 2017-04-17T10:06:21.386Z,
retryable: true } } }
I Follow the tutorial (2 times ), but impossible to understand what is my problem.
I used the region eu-west-2 instead of us-east-1.
Did I forget something ?
From @fwang on Tue Apr 18 2017 17:35:39 GMT+0000 (UTC)
@flocve Could you double check if these two files exist ~/.aws/config and ~/.aws/credentials
~/.aws/config should look like
[default]
region = eu-west-2
~/.aws/credentials should look like
[default]
aws_access_key_id = AKIXXXXGMPQAP123XXXX
aws_secret_access_key = JOsGrXxxXl8o8bXxXxbOf1RoDw2guXXxxXXxx123
From @eliocapelati on Sat Apr 22 2017 23:11:35 GMT+0000 (UTC)
Hello,
Following these steps, I have been getting an error on LAMBDA_PROXY function of api gateway.
the response on request also includes the:
statusCode: 200, headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': true, }, body: ....
and if a error (500) occur, the status code is 200.
From @jayair on Sat Apr 22 2017 23:17:38 GMT+0000 (UTC)
@eliocapelati can you show me the full response that you are seeing?
From @eliocapelati on Sat Apr 22 2017 23:19:51 GMT+0000 (UTC)
Here a 404 errorā¦ I just changed the 500 to 404ā¦
Update 1
Here the code of response-libā¦
Update 2
And here my function (Ok, this is the getā¦ but the same symptom at all):
From @jayair on Mon Apr 24 2017 20:15:31 GMT+0000 (UTC)
@eliocapelati Iām a bit confused here. According to your code you are throwing the 404 error. That is how it should work right? There is no problem then right?
From @deivers on Wed May 10 2017 12:52:18 GMT+0000 (UTC)
Iām getting:
{ ResourceNotFoundException: Requested resource not found
at Request.extractError (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:673:14)
at Request.transition (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:675:12)
at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:673:14)
at Request.transition (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:675:12)
at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at callNextListener (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at IncomingMessage.onEnd (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/event_listeners.js:254:11)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
message: 'Requested resource not found',
code: 'ResourceNotFoundException',
time: 2017-05-10T12:45:43.839Z,
requestId: '9AD2PP6137PVQV7O652HGL5JE3VV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 15.609907065688 }
Itās not clear to me which resource isnāt found.
From @vfonsecapv on Thu May 11 2017 12:41:54 GMT+0000 (UTC)
Same problem here @deivers
From @jayair on Thu May 11 2017 17:46:29 GMT+0000 (UTC)
@deivers @vfonsecapv when are you seeing this error?
From @ryanjcruz on Sat May 13 2017 01:11:00 GMT+0000 (UTC)
`$ serverless webpack invoke --function create --path event.json
Serverless: Bundling with Webpackā¦
Time: 679ms
Asset Size Chunks Chunk Names
create.js 4.17 kB 0 [emitted] create
handler.js 2.28 kB 1 [emitted] handler
Serverless: Run function createā¦
Type Error ---------------------------------------------
Cannot read property 'handler' of undefined
`
Iām getting the error above when trying to run the test, not sure where to proceed from here.
Update: OK, my bad, turns out āfunctionsā isnāt aligned correctly and was tabbed, making it a property of provider. Untabbed it and works perfectly!
From @jayair on Sat May 13 2017 23:16:19 GMT+0000 (UTC)
@ryanjcruz Glad you figured it out. Just noticed somebody else is having a similar issue as well.
From @manoaj on Sun May 21 2017 06:23:10 GMT+0000 (UTC)
```bash
serverless webpack invoke --function create --path event.json
Serverless: Bundling with Webpackā¦
Time: 1287ms
Asset Size Chunks Chunk Names
create.js 6.35 kB 0 [emitted] create
handler.js 2.28 kB 1 [emitted] handler
Serverless: Run function createā¦
{ statusCode: 500,
headers:
{ āAccess-Control-Allow-Originā: ā*ā,
āAccess-Control-Allow-Credentialsā: true },
body: ā{āstatusā:false}ā }
When I invoke the create function I got the above error, I did everything as mentioned in the tutorial, I couldn't able to trace the error, kindly help me to resolve the issue.
If I change the callback function to ES6 promise then I got the 500 error response before that I got 200 response...
UPDATE: I wrongly passed the arguments name in the dynamodb-lib.js, it works fine now.
From @go4cas on Sun May 21 2017 08:49:39 GMT+0000 (UTC)
When running serverless webpack invoke --function create --path event.json
, I get the following:
Unexpected token import
From @go4cas on Sun May 21 2017 09:05:02 GMT+0000 (UTC)
Okay, I fixed this with:
npm install --save-dev babel-preset-es2015
And then, changed .babelrc
file:
{
"plugins": ["transform-runtime"],
"presets": ["react-app","es2015"]
}