Node lambda not writing to DynamoDB and no error The Next CEO of Stack OverflowWriting files in Node.jsHow to append to a file in Node?How to uninstall npm modules in node js?npm throws error without sudonode how to create a directory if doesn't exist?Node.js/Windows error: ENOENT, stat 'C:UsersRTAppDataRoamingnpm'UpdateItem in AWS DynamoDB using AWS Lambda (node)DynamoDB causing module initialization error in Node/LambdaScanning DynamoDB table not showing results from the column specified in ProjectionExpressionlocalStack dynamoDb is getting hanged with the the input item
Is a distribution that is normal, but highly skewed, considered Gaussian?
Is it professional to write unrelated content in an almost-empty email?
Computationally populating tables with probability data
Is there an equivalent of cd - for cp or mv
Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?
Is fine stranded wire ok for main supply line?
Is dried pee considered dirt?
Which one is the true statement?
What CSS properties can the br tag have?
Lucky Feat: How can "more than one creature spend a luck point to influence the outcome of a roll"?
How to find image of a complex function with given constraints?
Traveling with my 5 year old daughter (as the father) without the mother from Germany to Mexico
Is there a way to save my career from absolute disaster?
Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens
What was Carter Burke's job for "the company" in Aliens?
(How) Could a medieval fantasy world survive a magic-induced "nuclear winter"?
How do I fit a non linear curve?
TikZ: How to fill area with a special pattern?
Is there a reasonable and studied concept of reduction between regular languages?
Does Germany produce more waste than the US?
Is French Guiana a (hard) EU border?
Is it ever safe to open a suspicious HTML file (e.g. email attachment)?
Does higher Oxidation/ reduction potential translate to higher energy storage in battery?
Can you teleport closer to a creature you are Frightened of?
Node lambda not writing to DynamoDB and no error
The Next CEO of Stack OverflowWriting files in Node.jsHow to append to a file in Node?How to uninstall npm modules in node js?npm throws error without sudonode how to create a directory if doesn't exist?Node.js/Windows error: ENOENT, stat 'C:UsersRTAppDataRoamingnpm'UpdateItem in AWS DynamoDB using AWS Lambda (node)DynamoDB causing module initialization error in Node/LambdaScanning DynamoDB table not showing results from the column specified in ProjectionExpressionlocalStack dynamoDb is getting hanged with the the input item
var ddb = new AWS.DynamoDB(apiVersion: '2012-08-10')
AWS.config.update(region: 'eu-west-1')
var docClient = new AWS.DynamoDB.DocumentClient()
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId' : S: '001',
'questionText' : S: 'Richard Roe'
var putItemPromise = docClient.put(params).promise()
putItemPromise.then(function(data)
console.log("Added item:", JSON.stringify(data, null, 2));
).catch(function(err)
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
);
await putItemPromise
No error is returned. No success callback. When I use the wrong column name I get an error back from Dynamo. I've tried running the it locally and on lambda. It executes, and exits. No rows get added to the Table. What am I doing wrong?
Edit:
Here is my CF for the DynamoDB table:
QuestionsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: 'TC_QUESTIONS'
AttributeDefinitions:
- AttributeName: questionId
AttributeType: S
- AttributeName: questionText
AttributeType: S
KeySchema:
- AttributeName: questionId
KeyType: HASH
- AttributeName: questionText
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"
node.js aws-lambda amazon-dynamodb
add a comment |
var ddb = new AWS.DynamoDB(apiVersion: '2012-08-10')
AWS.config.update(region: 'eu-west-1')
var docClient = new AWS.DynamoDB.DocumentClient()
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId' : S: '001',
'questionText' : S: 'Richard Roe'
var putItemPromise = docClient.put(params).promise()
putItemPromise.then(function(data)
console.log("Added item:", JSON.stringify(data, null, 2));
).catch(function(err)
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
);
await putItemPromise
No error is returned. No success callback. When I use the wrong column name I get an error back from Dynamo. I've tried running the it locally and on lambda. It executes, and exits. No rows get added to the Table. What am I doing wrong?
Edit:
Here is my CF for the DynamoDB table:
QuestionsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: 'TC_QUESTIONS'
AttributeDefinitions:
- AttributeName: questionId
AttributeType: S
- AttributeName: questionText
AttributeType: S
KeySchema:
- AttributeName: questionId
KeyType: HASH
- AttributeName: questionText
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"
node.js aws-lambda amazon-dynamodb
add a comment |
var ddb = new AWS.DynamoDB(apiVersion: '2012-08-10')
AWS.config.update(region: 'eu-west-1')
var docClient = new AWS.DynamoDB.DocumentClient()
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId' : S: '001',
'questionText' : S: 'Richard Roe'
var putItemPromise = docClient.put(params).promise()
putItemPromise.then(function(data)
console.log("Added item:", JSON.stringify(data, null, 2));
).catch(function(err)
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
);
await putItemPromise
No error is returned. No success callback. When I use the wrong column name I get an error back from Dynamo. I've tried running the it locally and on lambda. It executes, and exits. No rows get added to the Table. What am I doing wrong?
Edit:
Here is my CF for the DynamoDB table:
QuestionsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: 'TC_QUESTIONS'
AttributeDefinitions:
- AttributeName: questionId
AttributeType: S
- AttributeName: questionText
AttributeType: S
KeySchema:
- AttributeName: questionId
KeyType: HASH
- AttributeName: questionText
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"
node.js aws-lambda amazon-dynamodb
var ddb = new AWS.DynamoDB(apiVersion: '2012-08-10')
AWS.config.update(region: 'eu-west-1')
var docClient = new AWS.DynamoDB.DocumentClient()
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId' : S: '001',
'questionText' : S: 'Richard Roe'
var putItemPromise = docClient.put(params).promise()
putItemPromise.then(function(data)
console.log("Added item:", JSON.stringify(data, null, 2));
).catch(function(err)
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
);
await putItemPromise
No error is returned. No success callback. When I use the wrong column name I get an error back from Dynamo. I've tried running the it locally and on lambda. It executes, and exits. No rows get added to the Table. What am I doing wrong?
Edit:
Here is my CF for the DynamoDB table:
QuestionsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: 'TC_QUESTIONS'
AttributeDefinitions:
- AttributeName: questionId
AttributeType: S
- AttributeName: questionText
AttributeType: S
KeySchema:
- AttributeName: questionId
KeyType: HASH
- AttributeName: questionText
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"
node.js aws-lambda amazon-dynamodb
node.js aws-lambda amazon-dynamodb
edited Mar 8 at 17:23
Bobby
asked Mar 8 at 15:57
BobbyBobby
1,19821024
1,19821024
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
'use strict';
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-1');
exports.handler = async (event) =>
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId': '001',
'questionText' : 'Richard Roe'
try
await docClient.put(params).promise()
catch (e)
console.log(e.message)
;
If your table exists and questionId is your partition key, the code above works.
I think you were mixing things up a little bit, because since you're using DocClient you don't need to specify DynamoDB's types anymore. And this was the problem on your code. Just specify the raw values (like I did above, passing the String itself) and it will work.
OK thanks, I removed the types, but am getting the same result. I added the Cloudformation for the Table. Am I missing something about the partition key?
– Bobby
Mar 8 at 17:25
I confirmed in the console that questionId is the partition key. Really stumped here, still not getting anything added to the table. Confirmed by looking at the console.
– Bobby
Mar 8 at 17:32
OK.. I had my code in a module that was being imported and called from the lambda handler. Moving this dynamo code directly into the handler, and everything works... Something about the way I'm organising the files/modules is wrong. Thanks for your help.
– Bobby
Mar 8 at 17:41
Perfect! You're more than welcome!
– Thales Minussi
Mar 8 at 17:51
1
That was indeed it - I was missing an await. Thanks again :)
– Bobby
Mar 12 at 16:26
|
show 2 more comments
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55066777%2fnode-lambda-not-writing-to-dynamodb-and-no-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
'use strict';
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-1');
exports.handler = async (event) =>
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId': '001',
'questionText' : 'Richard Roe'
try
await docClient.put(params).promise()
catch (e)
console.log(e.message)
;
If your table exists and questionId is your partition key, the code above works.
I think you were mixing things up a little bit, because since you're using DocClient you don't need to specify DynamoDB's types anymore. And this was the problem on your code. Just specify the raw values (like I did above, passing the String itself) and it will work.
OK thanks, I removed the types, but am getting the same result. I added the Cloudformation for the Table. Am I missing something about the partition key?
– Bobby
Mar 8 at 17:25
I confirmed in the console that questionId is the partition key. Really stumped here, still not getting anything added to the table. Confirmed by looking at the console.
– Bobby
Mar 8 at 17:32
OK.. I had my code in a module that was being imported and called from the lambda handler. Moving this dynamo code directly into the handler, and everything works... Something about the way I'm organising the files/modules is wrong. Thanks for your help.
– Bobby
Mar 8 at 17:41
Perfect! You're more than welcome!
– Thales Minussi
Mar 8 at 17:51
1
That was indeed it - I was missing an await. Thanks again :)
– Bobby
Mar 12 at 16:26
|
show 2 more comments
'use strict';
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-1');
exports.handler = async (event) =>
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId': '001',
'questionText' : 'Richard Roe'
try
await docClient.put(params).promise()
catch (e)
console.log(e.message)
;
If your table exists and questionId is your partition key, the code above works.
I think you were mixing things up a little bit, because since you're using DocClient you don't need to specify DynamoDB's types anymore. And this was the problem on your code. Just specify the raw values (like I did above, passing the String itself) and it will work.
OK thanks, I removed the types, but am getting the same result. I added the Cloudformation for the Table. Am I missing something about the partition key?
– Bobby
Mar 8 at 17:25
I confirmed in the console that questionId is the partition key. Really stumped here, still not getting anything added to the table. Confirmed by looking at the console.
– Bobby
Mar 8 at 17:32
OK.. I had my code in a module that was being imported and called from the lambda handler. Moving this dynamo code directly into the handler, and everything works... Something about the way I'm organising the files/modules is wrong. Thanks for your help.
– Bobby
Mar 8 at 17:41
Perfect! You're more than welcome!
– Thales Minussi
Mar 8 at 17:51
1
That was indeed it - I was missing an await. Thanks again :)
– Bobby
Mar 12 at 16:26
|
show 2 more comments
'use strict';
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-1');
exports.handler = async (event) =>
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId': '001',
'questionText' : 'Richard Roe'
try
await docClient.put(params).promise()
catch (e)
console.log(e.message)
;
If your table exists and questionId is your partition key, the code above works.
I think you were mixing things up a little bit, because since you're using DocClient you don't need to specify DynamoDB's types anymore. And this was the problem on your code. Just specify the raw values (like I did above, passing the String itself) and it will work.
'use strict';
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-1');
exports.handler = async (event) =>
const params =
TableName: 'TC_QUESTIONS',
Item:
'questionId': '001',
'questionText' : 'Richard Roe'
try
await docClient.put(params).promise()
catch (e)
console.log(e.message)
;
If your table exists and questionId is your partition key, the code above works.
I think you were mixing things up a little bit, because since you're using DocClient you don't need to specify DynamoDB's types anymore. And this was the problem on your code. Just specify the raw values (like I did above, passing the String itself) and it will work.
answered Mar 8 at 16:22
Thales MinussiThales Minussi
1,545419
1,545419
OK thanks, I removed the types, but am getting the same result. I added the Cloudformation for the Table. Am I missing something about the partition key?
– Bobby
Mar 8 at 17:25
I confirmed in the console that questionId is the partition key. Really stumped here, still not getting anything added to the table. Confirmed by looking at the console.
– Bobby
Mar 8 at 17:32
OK.. I had my code in a module that was being imported and called from the lambda handler. Moving this dynamo code directly into the handler, and everything works... Something about the way I'm organising the files/modules is wrong. Thanks for your help.
– Bobby
Mar 8 at 17:41
Perfect! You're more than welcome!
– Thales Minussi
Mar 8 at 17:51
1
That was indeed it - I was missing an await. Thanks again :)
– Bobby
Mar 12 at 16:26
|
show 2 more comments
OK thanks, I removed the types, but am getting the same result. I added the Cloudformation for the Table. Am I missing something about the partition key?
– Bobby
Mar 8 at 17:25
I confirmed in the console that questionId is the partition key. Really stumped here, still not getting anything added to the table. Confirmed by looking at the console.
– Bobby
Mar 8 at 17:32
OK.. I had my code in a module that was being imported and called from the lambda handler. Moving this dynamo code directly into the handler, and everything works... Something about the way I'm organising the files/modules is wrong. Thanks for your help.
– Bobby
Mar 8 at 17:41
Perfect! You're more than welcome!
– Thales Minussi
Mar 8 at 17:51
1
That was indeed it - I was missing an await. Thanks again :)
– Bobby
Mar 12 at 16:26
OK thanks, I removed the types, but am getting the same result. I added the Cloudformation for the Table. Am I missing something about the partition key?
– Bobby
Mar 8 at 17:25
OK thanks, I removed the types, but am getting the same result. I added the Cloudformation for the Table. Am I missing something about the partition key?
– Bobby
Mar 8 at 17:25
I confirmed in the console that questionId is the partition key. Really stumped here, still not getting anything added to the table. Confirmed by looking at the console.
– Bobby
Mar 8 at 17:32
I confirmed in the console that questionId is the partition key. Really stumped here, still not getting anything added to the table. Confirmed by looking at the console.
– Bobby
Mar 8 at 17:32
OK.. I had my code in a module that was being imported and called from the lambda handler. Moving this dynamo code directly into the handler, and everything works... Something about the way I'm organising the files/modules is wrong. Thanks for your help.
– Bobby
Mar 8 at 17:41
OK.. I had my code in a module that was being imported and called from the lambda handler. Moving this dynamo code directly into the handler, and everything works... Something about the way I'm organising the files/modules is wrong. Thanks for your help.
– Bobby
Mar 8 at 17:41
Perfect! You're more than welcome!
– Thales Minussi
Mar 8 at 17:51
Perfect! You're more than welcome!
– Thales Minussi
Mar 8 at 17:51
1
1
That was indeed it - I was missing an await. Thanks again :)
– Bobby
Mar 12 at 16:26
That was indeed it - I was missing an await. Thanks again :)
– Bobby
Mar 12 at 16:26
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55066777%2fnode-lambda-not-writing-to-dynamodb-and-no-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown