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

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived