title: Data Item not getting inserted in DynamoDB Table from AWS Lambda Trigger
body: <p><strong>I have this Lambda code setup in JS for inserting a row in DynamoDB but the code seems to have some issue and doesn't trigger.Unable to figure out the issue as cloud watch also does captures anything. The API Gateway triggers the Lambda will inserts a row in DynamoDB. Tried debugging with console and logs also but unable to figure out the actual issue that is causing the code to break.</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>exports.handler = async (event) =&gt; {
  
      console.log(event);
  
      var eventBody = JSON.parse(event.body);
      var eventType = eventBody.event_type;
      var content = eventBody.content;
  
      if (content.subscription) { 
  
          var subscription = content.subscription;
  
          switch (eventType) {
  
              case "subscription_created":
                  // Add new entry to License table
  
                  console.log('subscription created event');
  
                  var customer = content.customer;
  
                  var findUserScan = {
                      ExpressionAttributeValues: {
                          ':email': { S: customer.email },
                      },
                      FilterExpression: 'email = :email',
                      TableName: _dynamodb_userprofile_table
                  };
  
                  try {
  
                      await dynamodb.scan(findUserScan, function (err, data) {
                          if (err) {
                              console.log("Error", err);
                          } else {
                              var userProfileAWS;
  
                              data.Items.forEach(function (userProfile, index, array) {
                                  userProfileAWS = AWS.DynamoDB.Converter.unmarshall(userProfile);
                              });
  
                             
  
                              var companyName;
  
                              if (userProfileAWS) {
                                  companyName = userProfileAWS.organization;
                              }
  
                              
  
                              try {
                                  var licenseEntry = {
                                      "subscriptionID": {
                                          S: subscription.id
                                      },
                                     
                                      "companyName": {
                                          S: companyName || ""
                                      },
                                      "customerEmail": {
                                          S: customer.email
                                      },
                                      
                                  };
  
                             
  
                                  await dynamodb.putItem({
                                      "TableName": _dynamodb_license_table,
                                      "Item": licenseEntry
                                  }).promise()
  
                              } catch (error) {
                                  console.log(error)
                                  throw new Error(`Error in dynamoDB: ${JSON.stringify(error)}`);
                              }
                          }
                      }).promise();
                  } catch (error) {
                      throw new Error(`Error in dynamoDB: ${JSON.stringify(error)}`);
                  }
                  break;</code></pre>
  </div>
  </div>
  </p>