-
Notifications
You must be signed in to change notification settings - Fork 6
/
madness.py
37 lines (32 loc) · 1.03 KB
/
madness.py
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
import boto3
class Actions(object):
def __init__(self, region, instance):
self.client = boto3.client('ec2', region)
self.instance = instance
def burn_instance(self):
response = self.client.terminate_instances(
DryRun=True,
InstanceIds=[
self.instance
]
)
return response
def stop_instance(self):
response = self.client.stop_instances(
DryRun=True,
InstanceIds=[
self.instance
]
)
return response
class fullMadness(object):
def __init__(self, inventory):
self.inventory = inventory
def burn_them_all(self):
for region in self.inventory:
for instance in self.inventory[region]:
action = Actions(region, instance['instance_id'])
try:
action.burn_instance()
except:
pass