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










1















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"









share|improve this question




























    1















    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"









    share|improve this question


























      1












      1








      1








      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"









      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 17:23







      Bobby

















      asked Mar 8 at 15:57









      BobbyBobby

      1,19821024




      1,19821024






















          1 Answer
          1






          active

          oldest

          votes


















          1














          '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.






          share|improve this answer























          • 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











          Your Answer






          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
          );



          );













          draft saved

          draft discarded


















          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









          1














          '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.






          share|improve this answer























          • 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















          1














          '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.






          share|improve this answer























          • 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













          1












          1








          1







          '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.






          share|improve this answer













          '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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page