Amazon Web Services Delete item on DynamoDB Database from Lambda Function

0 votes

How can I delete an item from a DynamoDB database from a Lambda function. I know how to put and item. Here is working code:

dynamo.putItem({
            "TableName": "Table",
            "Item": item
        }, function(err, data) {
            if (err) {
                console.log("Failure: " + err);
                context.succeed("Failure!");
                context.done();
            } else {
                console.log("Success!");
                context.succeed("Success!");
                context.done();
            }
        });
Feb 16, 2022 in AWS by Rahul
• 2,120 points
942 views

1 answer to this question.

0 votes
Omitting the Lambda boilerplate

     var tablename= "Users"

dynamodb.deleteItem({

"TableName": tableName

"Key": {

         "UserId"=event.UserId

      }

}, function (err, data) {

if (err) {

            context.fail('FAIL': Error deleting item from dynamodb', +err);

}

else {

        console.log("DEBUG: deleteItem worked.");

        context.succeed(data);

     }

}
answered Feb 16, 2022 by anonymous

Related Questions In AWS

+2 votes
1 answer

How PCF (Pivotal Cloud Foundry) is different from AWS (Amazon Web Services)

PCF (Pivotal Cloud Foundry)is a commercial cloud ...READ MORE

answered Sep 11, 2018 in AWS by Priyaj
• 58,020 points
21,651 views
0 votes
1 answer
+1 vote
3 answers

Not able to pass params POST to AWS Lambda from Amazon API Gateway

For this template : application/x-www-form-urlencoded  This line below will ...READ MORE

answered Jun 13, 2018 in AWS by Cloud gunner
• 4,670 points
8,769 views
0 votes
1 answer

How can i copy tables from one database to other on AWS?

You can use AWS Data pipeline to ...READ MORE

answered Jul 5, 2018 in AWS by Priyaj
• 58,020 points
4,820 views
0 votes
1 answer

Web Hosting on Amazon AWS (PHP + MySQL)

You can simply refer the following link, ...READ MORE

answered Aug 7, 2018 in AWS by Priyaj
• 58,020 points
1,192 views
0 votes
1 answer

How to link AWS Lambda function to Amazon CloudWatch ?

In order to create Log Group and ...READ MORE

answered Jul 20, 2018 in AWS by datageek
• 2,540 points
1,586 views
0 votes
1 answer

Access Amazon RDS database in VPC from Lambda locally

Your database is not connected to the ...READ MORE

answered Feb 14, 2022 in AWS by Rahul
• 2,120 points
577 views
0 votes
1 answer

Add a new item to a Dynamodb using a AWS lambda function each time a function is executed with Cloudwatch

The problem here is that the PutItem ...READ MORE

answered Feb 14, 2022 in AWS by Rahul
• 2,120 points
612 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP