-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.js
More file actions
63 lines (48 loc) · 1.58 KB
/
delete.js
File metadata and controls
63 lines (48 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const Promise = require("bluebird");
const AWS = require('aws-sdk');
const awsRegion = 'us-east-1';
AWS.config.update({region: awsRegion});
const ec2 = new AWS.EC2({apiVersion: '2016-11-15'});
Promise.promisifyAll(Object.getPrototypeOf(ec2));
const elb = new AWS.ELB({apiVersion: '2012-06-01'});
Promise.promisifyAll(Object.getPrototypeOf(elb));
const autoScaling = new AWS.AutoScaling({apiVersion: '2011-01-01'});
Promise.promisifyAll(Object.getPrototypeOf(autoScaling));
const elbParams = {
LoadBalancerName:'simple-elb'
};
const launchParams = {
LaunchConfigurationName: 'simple-launch-configuration'
};
const autoScaleParams = {
AutoScalingGroupName: 'simple-auto-scaling',
ForceDelete: true
};
deleteELB = function() {
return new Promise(function (resolve, reject) {
elb.deleteLoadBalancer(elbParams, function(err, data){
if (err) console.log(err, err.stack);
else console.log(JSON.stringify(data));
});
});
};
deleteLaunchConfig = function() {
return new Promise(function (resolve, reject) {
autoScaling.deleteLaunchConfiguration(launchParams, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(JSON.stringify(data));
});
});
}
deleteAutoScaling = function() {
return new Promise(function (resolve, reject) {
autoScaling.deleteAutoScalingGroup(autoScaleParams, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(JSON.stringify(data));
});
});
};
var elbAutoDelete = Promise.all([deleteELB(), deleteAutoScaling()]);
elbAutoDelete.then(deleteLaunchConfig());
//deleteAutoScaling();
//deleteLaunchConfig();