-
-
Notifications
You must be signed in to change notification settings - Fork 444
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
Comments: Add a Create Note API #23
Comments
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. |
Oh yeah you're right. Just fixed it - 8758786 |
When testing the code, I'm getting a 500 response. How do I troubleshoot this? |
@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. |
Thanks, that helped. My problem was naming one of the keys
|
Hello,
content of DynamoDB object :
And the error is :
I Follow the tutorial (2 times :) ), but impossible to understand what is my problem. Did I forget something ? |
@flocve Could you double check if these two files exist ~/.aws/config and ~/.aws/credentials ~/.aws/config should look like
~/.aws/credentials should look like
|
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. |
@eliocapelati can you show me the full response that you are seeing? |
@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? |
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. |
Same problem here @deivers |
@deivers @vfonsecapv when are you seeing this error? |
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! |
@ryanjcruz Glad you figured it out. Just noticed somebody else is having a similar issue as well. |
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. UPDATE: I wrongly passed the arguments name in the dynamodb-lib.js, it works fine now. |
When running
|
Okay, I fixed this with:
And then, changed
|
Hi, everyone. I need your help, please!!! When I running serverless webpack invoke --function create --path event.json the result is this: **import _JSON$stringify from 'babel-runtime/core-js/json/stringify';**
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ServerlessWebpack.loadHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/serverless-webpack/lib/run.js:21:20)
at ServerlessWebpack.run (/Users/sapo/Development/notes/notes-app-api/node_modules/serverless-webpack/lib/run.js:61:26)
at ServerlessWebpack.tryCatcher (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:638:18)
at Promise._resolveCallback (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:432:57)
at Promise._settlePromiseFromHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:524:17)
at Promise._settlePromise (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:638:18)
From previous event:
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:234:22)
at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:253:17)
at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:96:33)
From previous event:
at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:87:74)
at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:23:50)
Your Environment Information -----------------------------
OS: darwin
Node Version: 6.9.4
Serverless Version: 1.13.2 Thanks!!! |
@go4cas That's weird, the |
@martinsaporiti this looks like the same issue as @go4cas. Let me check what is going on. |
@martinsaporiti @go4cas You guys are right, there is an issue with the new |
Thanks @jayair and @go4cas ! Now work perfectly:
I will continue with the tutorial. It's very useful. |
@jayair I'm running into the same problem as @deivers and @vfonsecapv when I run the test with event.json. I do have multiple profiles and I'm not using the default profile in this case. I'm using us-west-2 and I believe I already changed that everywhere in the code. Any clue how I can debug? |
nevermind, I figured it out. If you're not using your default profile then in your create.js you need to do |
@oliv9286 Thanks for reporting back. Are you setting this in the top of your |
I also get the same error as @deivers and @vfonsecapv . When I run
I get
Note that I didnt install the serverless module as global. |
@tobyjo can I take a look at your serverless.yml? |
@nelsoftcom I'm not sure if you didn't paste it properly but it needs to be indented exactly like this https://github.com/AnomalyInnovations/serverless-stack-demo-api/blob/master/serverless.yml |
@jayair I'm running 1.26.1 |
@jayair Thank you. Passed that level - yes indent was the issue. Now I', getting status code 500
|
@nelsoftcom This is pretty common and we have a little note at the bottom of the chapter for it - https://serverless-stack.com/chapters/add-a-create-note-api.html#common-issues @sarahbattey That looks okay. I'm not entirely sure what the issue is. Can you share your directory structure and show me where you are running your command from? |
@jayair thank you :) create-event and get-event works. thanks for the help. |
@jayair here's a screenshot of my file structure and my serverless.yml too, just in case. I can't thank you enough for your help! Edit: ...and a shot of my cli: |
@sarahbattey Yeah the structure is a bit weird. Compare it to the one we have in the tutorial - https://github.com/AnomalyInnovations/serverless-stack-demo-api. And you run your serverless commands at the level where your |
@jayair Wow...I have NO idea what happened there. I'm going to restart. This will be my third start (the first try was due to Route 53 and not you)...I'm doing this to get more familiar with AWS and React so every error and every weird thing is a learning experience! Thanks again for everything you've done! |
Can you comment on why the functions are async? I would think the simpler approach would be to make calls synchronous unless there is a need for async calls. I'm asking because I wanted to try and reuse some of the basic CRUD functions but am having problems with the async sub functions. |
@curtisolson I'm not sure if there are synchronous versions of the DynamoDB calls but if there are, then you could use them and not have the Lambda function be async. |
I'm running $ serverless invoke local --function create --path mocks/create-event.json My return is:
It appears to be a permissions/IAM issue: I don't want to go in and just start changing permissions. I feel like I'm missing some fundamental lesson or item that I should know before moving on. Any help would be very much appreciated. |
@TinCharMan This permission is coming from your |
Based on @oliv9286 's comment, I used the following to set non-default credentials. diff --git a/libs/dynamodb-lib.js b/libs/dynamodb-lib.js
index f08b4d8..de2b4f0 100644
--- a/libs/dynamodb-lib.js
+++ b/libs/dynamodb-lib.js
@@ -1,6 +1,7 @@
import AWS from "aws-sdk";
-AWS.config.update({ region: "us-east-1" });
+const credentials = new AWS.SharedIniFileCredentials({profile: 'personal'});
+AWS.config.update({ region: "us-east-1", credentials: credentials });
export function call(action, params) {
const dynamoDb = new AWS.DynamoDB.DocumentClient(); |
@ahammond So this would work when invoking locally but when you deploy the Lambda function won't be able to find the
Did that not work for you? |
Thank you @jayair . Worked! |
@F-Adam-B Is the issue resolved for you? I'm facing the same problem.. |
@abhisheksett What's the issue? |
I was facing the same issue mentioned by @F-Adam-B , saying
That got resolved by exporting AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Now I'm getting following error:
Am I missing any configuration? |
@abhisheksett When are you seeing this error? |
I'm getting this error when I'm trying to create a note by following command:
|
@abhisheksett This seems like it is complaining about not finding your DynamoDB table. Can I see your |
This issue was moved to https://discourse.serverless-stack.com/t/comments-add-a-create-note-api/125 |
@jayair, I'm running into this issue when I run: Serverless: DOTENV: Loading environment variables from .env: Syntax Error ------------------------------------------- SyntaxError: Unexpected end of JSON input
Get Support -------------------------------------------- Your Environment Information --------------------------- |
Please post this over on our forums! |
I'm unable to post on the forums as a new user for now so that's why I posted here.... |
Weird. I think it just got caught by the spam detection. I think I allowed it. Can you post in there now? |
I had this error. It was because I forgot to create the table in DynamoDB |
Link to chapter - http://serverless-stack.com/chapters/add-a-create-note-api.html
The text was updated successfully, but these errors were encountered: