Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"use strict";
const AWS = require("aws-sdk");
AWS.config.update({ region: "eu-central-1" });
class RDSInstance {
constructor(identifier) {
this.rds = new AWS.RDS();
this.identifier = identifier;
this.load();
}
load(identifier){
if(!!identifier){
this.identifier = identifier;
}
let self = this;
return new Promise((resolve, reject) => {
this.rds.describeDBInstances({DBInstanceIdentifier: self.identifer}, (err, resp) => {
!!err && return reject(err);
return resolve(resp.DBInstances[0]);
});
});
}
}
module.exports = RDSInstance;
@webertrlz

This comment has been minimized.

Copy link
Owner Author

webertrlz commented Jul 15, 2019

Then I would use it like:

const RDSInstance = require("./rds-instance");
rds = new RDSInstance(identifier);

rds.doSomethingElse() // this also returns a Promise, but I have to be sure that the load function was completed
.then(res => {})
.catch(err => {})
@webertrlz

This comment has been minimized.

Copy link
Owner Author

webertrlz commented Jul 15, 2019

Answer: don't do it, it's stupid/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.