-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteelb.py
54 lines (45 loc) · 997 Bytes
/
deleteelb.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#####
#
# Creates RDS instance for Wordpress
# deleteelb.py
#
#####
import boto3
import sys, json, time
import conf
elb=boto3.client('elbv2')
ec2=boto3.client('ec2')
ec2r=boto3.resource('ec2')
try:
#get arn for target group
tgarn=elb.describe_target_groups(Names=['jbme-tg'])['TargetGroups'][0]['TargetGroupArn']
response = elb.delete_target_group(
TargetGroupArn=tgarn
)
except Exception as e:
print "Failed to delete target group"
print e
sys.exit()
print "Deleted Target Group %s" % (tgarn)
try:
response = ec2.delete_security_group(
GroupName='jbme-elb-sg'
)
except Exception as e:
print "Failed to delete security group"
print e
sys.exit()
print "Deleted security Group"
try:
#Get load balancer ARN
lbarn = elb.describe_load_balancers(
Names=[
'jbme-elb'
],
)['LoadBalancers'][0]['LoadBalancerArn']
response=elb.delete_load_balancer(LoadBalancerArn=lbarn)
except:
print "Failed to delete ELB"
print e
sys.exit()
print "Deleted ELB"