I need to start and stop an instance of RDS from a nodejs script.
But I read the AWS documentation but I didn't see how to do it.
I have installed aws-sdk and I'm trying to use it like this:
const aws = require("aws-sdk");
const test = new aws.RDS({
apiVersion: "XXXX",
accessKeyId: "",
secretAccessKey: "",
region: "XXXXX",
endpoint: "XXXXXX"
});
is there a better way to implement this functionality?
Thanks in advance,
Javier
After initializing the Service like you did, you can call startDBInstance
var params = {
DBInstanceIdentifier: 'STRING_VALUE' /* required */
};
test.startDBInstance(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
and stopDBInstance
:
var params = {
DBInstanceIdentifier: 'STRING_VALUE', /* required */
DBSnapshotIdentifier: 'STRING_VALUE'
};
test.stopDBInstance(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
Refer to docs: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/RDS.html#startDBInstance-property
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.