Created
May 1, 2020 20:39
-
-
Save mick-shaw/f27c82a088a82972c436271dff2cf44d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Load the AWS SDK for Node.js | |
| var AWS = require('aws-sdk'); | |
| // Quick CLI method for deleting a DynamoDB Item | |
| // CLI Command: node ./deleteit.js <item value? | |
| // | |
| // Load the AWS SDK for Node.js | |
| var AWS = require('aws-sdk'); | |
| AWS.config.loadFromPath('./onfig.json'); | |
| const args = process.argv.slice(2) | |
| function deleteItem(Record){ | |
| // Load the AWS SDK for Node.js | |
| var AWS = require('aws-sdk'); | |
| // Set the region | |
| AWS.config.update({region: 'us-east-1'}); | |
| // Create the DynamoDB service object | |
| ddb = new AWS.DynamoDB({ | |
| apiVersion: '2012-08-10' | |
| }); | |
| var params = { | |
| Key: { | |
| "Record": { | |
| S : Record | |
| }, | |
| }, | |
| TableName: "RecordLocator" | |
| }; | |
| ddb.deleteItem(params, function(err, data){ | |
| if(err){ | |
| console.log(err, err.stack); | |
| return err; | |
| } | |
| else{ | |
| return | |
| } | |
| }); | |
| } | |
| deleteItem(args[0]); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| input="/deletethese.csv" | |
| while IFS= read -r LINE; | |
| do /usr/local/n/versions/node/11.2.0/bin/node /deleteItem.js "$LINE" | |
| echo "deleting $LINE" | |
| done < "$input" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment