in source/state_machine_handler.py [0:0]
def default_route_crud_operations(self):
try:
self.logger.info("Executing: " + self.__class__.__name__ + "/" + inspect.stack()[0][3])
# this condition will be met if VPC tagged not Subnet
if self.event.get('SubnetId') is not None:
ec2 = self._session(self.spoke_region, self.spoke_account_id)
existing_routes = self._describe_route_tables_for_subnet()
# handles the case if the subnet has no association with
# explicit route table
if existing_routes is None:
return self.event
# allowed values in hub CFN template
# "All-Traffic (0/0)"
# "RFC-1918 (10/8, 172.16/12, 192.168/16)"
# "Custom Destinations"
# "Configure-Manually
quad_zero_route = environ.get('ALL_TRAFFIC') # 0.0.0.0/0
rfc_1918_routes = convert_string_to_list(
environ.get('RFC_1918_ROUTES'))
if "All-Traffic" in environ.get('DEFAULT_ROUTE'):
self._find_existing_default_route(existing_routes,
quad_zero_route)
self._update_route_table(ec2, quad_zero_route)
elif "RFC-1918" in environ.get('DEFAULT_ROUTE'):
for route in rfc_1918_routes:
self._find_existing_default_route(existing_routes,
route)
self._update_route_table(ec2, route)
elif "Custom-Destinations" in environ.get('DEFAULT_ROUTE'):
self.update_route_table_with_cidr_blocks(ec2,
existing_routes)
self.update_route_table_with_prefix_lists(ec2,
existing_routes)
elif "Configure-Manually" in environ.get('DEFAULT_ROUTE'):
self.logger.info('Admin opted to configure route '
'table manually')
return self.event
except Exception as e:
message = self._message(inspect.stack()[0][3], e)
self.logger.exception(message)
self._update_ddb_failed(e)
raise