vpc.py¶
-
class
botoform.enriched.vpc.
EnrichedVPC
(vpc_name=None, region_name=None, profile_name=None, log=None)¶ This class uses composition to enrich Boto3’s VPC resource class. Here we relate AWS resources using various techniques like the vpc_name tag. We also provide methods for managing the lifecycle of related AWS resources.
-
associate_route_table_with_subnet
(rt_name, sn_name)¶ Accept a route table name and subnet name, associate them.
-
attach_vpn_gateway
(vgw_id)¶ Attach VPN gateway to the VPC
-
azones
¶
-
connect
(vpc_name)¶ connect to VPC and reflect all attributes into self.
-
delete_dhcp_options
()¶ Delete DHCP Options Set
-
delete_instances
(instances=None, wait=True)¶ Terminate all or a list of instances.
-
delete_internet_gateways
()¶ Delete related internet gatways.
-
delete_route_tables
()¶ Delete related route tables.
-
delete_security_group
(**kw)¶
-
delete_security_groups
()¶ Delete related security groups.
-
delete_subnets
()¶ Delete related subnets.
-
detach_vpn_gateway
()¶ Detach VPN gateway from VPC
-
enriched_security_groups
¶ Format Security Groups (and permissions) in Botoform Schema.
Returns: security_groups in Botoform Schema.
-
ensure_vgw_state
(**kw)¶ if vgw is not in expected state, throw exception.
-
exclude_instances
(identifiers=None, roles=None)¶ Accept a list of identifiers and/or roles. Return a list of instances which do not match either qualifier list.
- Note:
- This method returns all instances if both identfiers and roles is None.
-
find_instance
(identifier)¶ Return an instance or None which matches identifier.
Raises exception if multiple instances match identifier.
Parameters: identifier – - A list of identifiers to qualify instances by, for example:
- custid-ui01
- ui01
- 192.168.1.9
- i-01234567
Returns: EnrichedInstance or None
-
find_instances
(identifiers=None, roles=None, exclude=False)¶ Accept a list of identifiers and/or roles. Return a list of instances which match either qualifier list.
Parameters: - identifiers –
- Optional, a list of identifiers to qualify instances by, for example:
- custid-ui01
- ui01
- 192.168.1.9
- i-01234567
- roles –
- Optional, a list of roles to qualify instances by, for example:
- ui
- api
- proxy
- exclude – If True, qualifiers exclude instead of include! Defaults to False.
- Danger:
- This method will return no instances if all qualifiers are None. However, if exclude is True we could return all instances!
Returns: A list of EnrichedInstance objets or an empty list. - identifiers –
-
get_autoscaled_instances
(instances=None)¶ return a list of instances which were created via autoscaling.
-
get_instances
(instances=None)¶ Returns a possibly empty list of EnrichedInstance objects.
Parameters: instances – Optional, list or collection to convert to EnrichedInstance objects. Returns: list of EnrichedInstance objects
-
get_main_route_table
()¶ Return the main (default) route table for VPC.
-
get_normal_instances
(instances=None)¶ return a list of instances which were _not_ created via autoscaling.
-
get_role
(role_name, instances=None)¶ Return a possibly empty list of EnrichedInstance objects.
Parameters: - role_name – The name of the role whose instances to return.
- instances – Optional, list or collection to search role from.
Returns: A list of EnrichedInstance objects.
-
get_roles
(instances=None)¶ Return a dict of lists where role is the key and a list of EnrichedInstance objects is the value.
-
get_route_table
(name)¶ Accept route table name, return route_table object or None.
-
get_running_instances
(instances=None)¶ Return list running EnrichedInstance object related to this VPC.
-
get_security_group
(name)¶ Accept security group name, return security group object or None.
-
get_subnet
(name)¶ Accept subnet name, return subnet object or None.
-
get_vgw
(vgw_id)¶ Accept vgw_id and return vgw description.
-
get_vpc_by_name_tag
(vpc_name)¶ lookup vpc by vpc_name tag. Raises exceptions on insanity.
-
get_vpn_gateways
()¶ Gets all the VGWs attached to the VPC
-
identity
¶
-
include_instances
(identifiers=None, roles=None)¶ Accept a list of identifiers and/or roles. Return a list of instances which match either qualifier list.
- Note:
- This method returns no instances if both identfiers and roles is None.
-
instances
¶
-
lock_instances
(instances=None)¶ Lock all or a list of instances.
-
name
¶
-
reflect_attrs
()¶ reflect all attributes of boto3’s vpc resource object into self.
-
region_name
¶
-
reload
()¶ run the reload method on the attached instance and reflect_attrs.
-
revoke_inbound_rules_from_sg
(sg)¶
-
revoke_outbound_rules_from_sg
(sg)¶
-
revoke_security_group_rules
(sg)¶
-
roles
¶
-
start_instances
(instances=None, wait=True)¶ Start all or a list of instances.
-
stop_instances
(instances=None, wait=True)¶ Stop all or a list of instances.
-
tag_dict
¶
-
taggable_resources
¶ Return a list of taggable objects related to this VPC.
-
terminate
()¶ Terminate all resources related to this VPC!
-
unlock_instances
(instances=None)¶ Unlock all or a list of instances.
-
wait_until_instances
(instances=None, state=None)¶
-