how to get aws VPC with all attached services like route table,insance,subnets and all using python boto? can do like tree strucres please if u have any idea share with me below code is i have did i have problems with filters can help with u r solutions pleas?
from boto.vpc import VPCConnection import boto.ec2 from boto.ec2 import EC2Connection
ec2_conn = EC2Connection()
ec2s = ec2_conn.get_all_instances()
region = boto.ec2.regions()
print region
print region[0]
vpc_conn = VPCConnection()
vpcs = vpc_conn.get_all_vpcs()
for vpc in vpcs:
print" %35s " %vpc
subnets = vpc_conn.get_all_subnets(filters={ 'vpc_id': vpc.id })
for subnet in subnets:
print" %45s " %subnet.id
'''print" %45s " %subnet.availability_zone
print" %45s " %subnet.cidr_block
print '' '''
route_tables = vpc_conn.get_all_route_tables(filters={ 'vpc_id': vpc.id })
for route in route_tables:
print" %55s " %route
print ''
acls = vpc_conn.get_all_network_acls(filters={ 'vpc_id': vpc.id })
for acl in acls:
print" %55s " %acl
print ''
enis = vpc_conn.get_all_network_interfaces(filters={ 'vpc_id': vpc.id })
for eni in enis:
print" %55s " %eni
print ''
instance = vpc_conn.get_all_instances(filters={ 'vpc_id': vpc.id})
for inst in instance:
print" %55s " %inst
typ = vpc_conn.get_all_internet_gateways(filters={'attachment.vpc-id':vpc.id}) for i in typ: print" %55s " %i
typ3 = vpc_conn.get_all_security_groups(filters={'vpc_id': vpc.id})
for t3 in typ3:
print" %55s " %t3
Aucun commentaire:
Enregistrer un commentaire