|
|
|
@ -189,6 +189,7 @@ def get_vpc_info(vpc):
|
|
|
|
|
'state': vpc.state,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def find_vpc(module, vpc_conn, vpc_id=None, cidr=None):
|
|
|
|
|
"""
|
|
|
|
|
Finds a VPC that matches a specific id or cidr + tags
|
|
|
|
@ -234,8 +235,8 @@ def find_vpc(module, vpc_conn, vpc_id=None, cidr=None):
|
|
|
|
|
|
|
|
|
|
return (found_vpc)
|
|
|
|
|
|
|
|
|
|
def routes_match(rt_list=None, rt=None, igw=None):
|
|
|
|
|
|
|
|
|
|
def routes_match(rt_list=None, rt=None, igw=None):
|
|
|
|
|
"""
|
|
|
|
|
Check if the route table has all routes as in given list
|
|
|
|
|
|
|
|
|
@ -284,6 +285,7 @@ def routes_match(rt_list=None, rt=None, igw=None):
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def rtb_changed(route_tables=None, vpc_conn=None, module=None, vpc=None, igw=None):
|
|
|
|
|
"""
|
|
|
|
|
Checks if the remote routes match the local routes.
|
|
|
|
@ -310,7 +312,7 @@ def rtb_changed(route_tables=None, vpc_conn=None, module=None, vpc=None, igw=Non
|
|
|
|
|
rsn = vpc_conn.get_all_subnets(filters={'cidr': sn, 'vpc_id': vpc.id})
|
|
|
|
|
if len(rsn) != 1:
|
|
|
|
|
module.fail_json(
|
|
|
|
|
msg='The subnet {0} to associate with route_table {1} ' \
|
|
|
|
|
msg='The subnet {0} to associate with route_table {1} '
|
|
|
|
|
'does not exist, aborting'.format(sn, rt)
|
|
|
|
|
)
|
|
|
|
|
nrt = vpc_conn.get_all_route_tables(filters={'vpc_id': vpc.id, 'association.subnet-id': rsn[0].id})
|
|
|
|
@ -408,7 +410,6 @@ def create_vpc(module, vpc_conn):
|
|
|
|
|
if new_tags:
|
|
|
|
|
vpc_conn.create_tags(vpc.id, new_tags)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# boto doesn't appear to have a way to determine the existing
|
|
|
|
|
# value of the dns attributes, so we just set them.
|
|
|
|
|
# It also must be done one at a time.
|
|
|
|
@ -548,7 +549,7 @@ def create_vpc(module, vpc_conn):
|
|
|
|
|
if route['gw'] == 'igw':
|
|
|
|
|
if not internet_gateway:
|
|
|
|
|
module.fail_json(
|
|
|
|
|
msg='You asked for an Internet Gateway ' \
|
|
|
|
|
msg='You asked for an Internet Gateway '
|
|
|
|
|
'(igw) route, but you have no Internet Gateway'
|
|
|
|
|
)
|
|
|
|
|
route_kwargs['gateway_id'] = igw.id
|
|
|
|
@ -567,7 +568,7 @@ def create_vpc(module, vpc_conn):
|
|
|
|
|
rsn = vpc_conn.get_all_subnets(filters={'cidr': sn, 'vpc_id': vpc.id})
|
|
|
|
|
if len(rsn) != 1:
|
|
|
|
|
module.fail_json(
|
|
|
|
|
msg='The subnet {0} to associate with route_table {1} ' \
|
|
|
|
|
msg='The subnet {0} to associate with route_table {1} '
|
|
|
|
|
'does not exist, aborting'.format(sn, rt)
|
|
|
|
|
)
|
|
|
|
|
rsn = rsn[0]
|
|
|
|
@ -591,7 +592,7 @@ def create_vpc(module, vpc_conn):
|
|
|
|
|
changed = True
|
|
|
|
|
except EC2ResponseError as e:
|
|
|
|
|
module.fail_json(
|
|
|
|
|
msg='Unable to create and associate route table {0}, error: ' \
|
|
|
|
|
msg='Unable to create and associate route table {0}, error: '
|
|
|
|
|
'{1}'.format(rt, e)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -647,6 +648,7 @@ def create_vpc(module, vpc_conn):
|
|
|
|
|
|
|
|
|
|
return (vpc_dict, created_vpc_id, returned_subnets, igw_id, changed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def terminate_vpc(module, vpc_conn, vpc_id=None, cidr=None):
|
|
|
|
|
"""
|
|
|
|
|
Terminates a VPC
|
|
|
|
|