Closed PeteDuncanson closed 3 years ago
You need to use the promise version mentioned in this comment https://github.com/enGMzizo/copy-dynamodb-table/issues/12#issuecomment-592869559 and update your code to support it.
var copy = require('copy-dynamodb-table').copy;
function promiseCopy(data) {
return new Promise((resolve, reject) => {
copy(data, function (err, result) {
if (err) {
return reject(err)
}
resolve(result)
})
})
}
var globalAWSConfig = {
accessKeyId: 'MYKEY',
secretAccessKey: 'MYSECRET',
region: 'eu-west-1'
};
async function copyTable( from, to ) {
console.info( "Copying table " + from + " to " + to );
await promiseCopy({
config: globalAWSConfig,
source: {
tableName: from, // required
},
destination: {
tableName: to, // required
},
log: true, // default false
create : true // create destination table if not exist
});
console.info( "Done?");
}
exports.handler = async (event) => {
console.info( event );
await copyTable( "my-source-table-dev", "my-target-table-live" );
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
I've setup a Lambda to run this but I must be doing something wrong. I've hardcoded the API keys and secret in to my code (taken from the AWS Console https://aws.amazon.com/blogs/security/how-to-find-update-access-keys-password-mfa-aws-management-console/).
The Lamba runs but nothing is happening with the code, no errors are reported and nothing in the logs. I'm running the Lambda via the Test button in the web interface which should pass in a dummy event but I can't see where this code needs any of the environment vars it would get from running it in any other way and again its not complaining about anything so I think that should be ok?
What am I doing wrong?