Skip to content

Instantly share code, notes, and snippets.

@mick-shaw
Created May 1, 2020 20:39
Show Gist options
  • Select an option

  • Save mick-shaw/f27c82a088a82972c436271dff2cf44d to your computer and use it in GitHub Desktop.

Select an option

Save mick-shaw/f27c82a088a82972c436271dff2cf44d to your computer and use it in GitHub Desktop.
// 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]);
#!/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