Created
August 10, 2018 05:34
-
-
Save pratheekhegde/3bc8ecc02737fc5e2ea09d6bc94dca90 to your computer and use it in GitHub Desktop.
Lamda function for taking manual RDS snapshot.
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
var AWS = require('aws-sdk'); | |
const rdsConfig = { | |
apiVersion: '2014-10-31', | |
accessKeyId: process.env.ACCESS_KEY, | |
secretAccessKey: process.env.SECRET_KEY, | |
region: process.env.REGION | |
} | |
const rds = new AWS.RDS(rdsConfig); | |
exports.handler = (event, context, callback) => { | |
const currentDate = new Date(); | |
const params = { | |
DBInstanceIdentifier: 'my-db', /* DB instance name */ | |
DBSnapshotIdentifier: `my-db-${currentDate.toDateString().replace(/\s+/g, '-').toLowerCase()}-snapshot-manual-by-lamda`, /* DB Snapshot name */ | |
}; | |
rds.createDBSnapshot(params, function(err, data) { | |
if (err) { | |
console.log(err, err.stack); // an error occurred | |
callback(err) | |
} | |
else { | |
callback(null, data);// successful response | |
console.log("Snapshot Created ..."); | |
} | |
}); | |
} |
I can't get this to work. Keeps timing out for some reason.
Also, do I need to add any layers?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what runtime need to select for run this