VPC

boto.vpc

Represents a connection to the EC2 service.

class boto.vpc.VPCConnection(aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, host=None, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/', api_version=None, security_token=None)

Init method to create a new connection to EC2.

associate_dhcp_options(dhcp_options_id, vpc_id)

Associate a set of Dhcp Options with a VPC.

Parameters:
  • dhcp_options_id (str) – The ID of the Dhcp Options
  • vpc_id (str) – The ID of the VPC.
Return type:

bool

Returns:

True if successful

associate_route_table(route_table_id, subnet_id)

Associates a route table with a specific subnet.

Parameters:
  • route_table_id (str) – The ID of the route table to associate.
  • subnet_id (str) – The ID of the subnet to associate with.
Return type:

str

Returns:

The ID of the association created

attach_internet_gateway(internet_gateway_id, vpc_id)

Attach an internet gateway to a specific VPC.

Parameters:
  • internet_gateway_id (str) – The ID of the internet gateway to delete.
  • vpc_id (str) – The ID of the VPC to attach to.
Return type:

Bool

Returns:

True if successful

attach_vpn_gateway(vpn_gateway_id, vpc_id)

Attaches a VPN gateway to a VPC.

Parameters:
  • vpn_gateway_id (str) – The ID of the vpn_gateway to attach
  • vpc_id (str) – The ID of the VPC you want to attach the gateway to.
Return type:

An attachment

Returns:

a boto.vpc.vpngateway.Attachment

create_customer_gateway(type, ip_address, bgp_asn)

Create a new Customer Gateway

Parameters:
  • type (str) – Type of VPN Connection. Only valid valid currently is ‘ipsec.1’
  • ip_address (str) – Internet-routable IP address for customer’s gateway. Must be a static address.
  • bgp_asn (str) – Customer gateway’s Border Gateway Protocol (BGP) Autonomous System Number (ASN)
Return type:

The newly created CustomerGateway

Returns:

A boto.vpc.customergateway.CustomerGateway object

create_dhcp_options(vpc_id, cidr_block, availability_zone=None)

Create a new DhcpOption

Parameters:
  • vpc_id (str) – The ID of the VPC where you want to create the subnet.
  • cidr_block (str) – The CIDR block you want the subnet to cover.
  • availability_zone (str) – The AZ you want the subnet in
Return type:

The newly created DhcpOption

Returns:

A boto.vpc.customergateway.DhcpOption object

create_internet_gateway()

Creates an internet gateway for VPC.

Return type:Newly created internet gateway.
Returns:boto.vpc.internetgateway.InternetGateway
create_route(route_table_id, destination_cidr_block, gateway_id=None, instance_id=None)

Creates a new route in the route table within a VPC. The route’s target can be either a gateway attached to the VPC or a NAT instance in the VPC.

Parameters:
  • route_table_id (str) – The ID of the route table for the route.
  • destination_cidr_block (str) – The CIDR address block used for the destination match.
  • gateway_id (str) – The ID of the gateway attached to your VPC.
  • instance_id (str) – The ID of a NAT instance in your VPC.
Return type:

bool

Returns:

True if successful

create_route_table(vpc_id)

Creates a new route table.

Parameters:vpc_id (str) – The VPC ID to associate this route table with.
Return type:The newly created route table
Returns:A boto.vpc.routetable.RouteTable object
create_subnet(vpc_id, cidr_block, availability_zone=None)

Create a new Subnet

Parameters:
  • vpc_id (str) – The ID of the VPC where you want to create the subnet.
  • cidr_block (str) – The CIDR block you want the subnet to cover.
  • availability_zone (str) – The AZ you want the subnet in
Return type:

The newly created Subnet

Returns:

A boto.vpc.customergateway.Subnet object

create_vpc(cidr_block)

Create a new Virtual Private Cloud.

Parameters:cidr_block (str) – A valid CIDR block
Return type:The newly created VPC
Returns:A boto.vpc.vpc.VPC object
create_vpn_connection(type, customer_gateway_id, vpn_gateway_id)

Create a new VPN Connection.

Parameters:
  • type (str) – The type of VPN Connection. Currently only ‘ipsec.1’ is supported
  • customer_gateway_id (str) – The ID of the customer gateway.
  • vpn_gateway_id (str) – The ID of the VPN gateway.
Return type:

The newly created VpnConnection

Returns:

A boto.vpc.vpnconnection.VpnConnection object

create_vpn_gateway(type, availability_zone=None)

Create a new Vpn Gateway

Parameters:
  • type (str) – Type of VPN Connection. Only valid valid currently is ‘ipsec.1’
  • availability_zone (str) – The Availability Zone where you want the VPN gateway.
Return type:

The newly created VpnGateway

Returns:

A boto.vpc.vpngateway.VpnGateway object

delete_customer_gateway(customer_gateway_id)

Delete a Customer Gateway.

Parameters:customer_gateway_id (str) – The ID of the customer_gateway to be deleted.
Return type:bool
Returns:True if successful
delete_dhcp_options(dhcp_options_id)

Delete a DHCP Options

Parameters:dhcp_options_id (str) – The ID of the DHCP Options to be deleted.
Return type:bool
Returns:True if successful
delete_internet_gateway(internet_gateway_id)

Deletes an internet gateway from the VPC.

Parameters:internet_gateway_id (str) – The ID of the internet gateway to delete.
Return type:Bool
Returns:True if successful
delete_route(route_table_id, destination_cidr_block)

Deletes a route from a route table within a VPC.

Parameters:
  • route_table_id (str) – The ID of the route table with the route.
  • destination_cidr_block (str) – The CIDR address block used for destination match.
Return type:

bool

Returns:

True if successful

delete_route_table(route_table_id)

Delete a route table.

Parameters:route_table_id (str) – The ID of the route table to delete.
Return type:bool
Returns:True if successful
delete_subnet(subnet_id)

Delete a subnet.

Parameters:subnet_id (str) – The ID of the subnet to be deleted.
Return type:bool
Returns:True if successful
delete_vpc(vpc_id)

Delete a Virtual Private Cloud.

Parameters:vpc_id (str) – The ID of the vpc to be deleted.
Return type:bool
Returns:True if successful
delete_vpn_connection(vpn_connection_id)

Delete a VPN Connection.

Parameters:vpn_connection_id (str) – The ID of the vpn_connection to be deleted.
Return type:bool
Returns:True if successful
delete_vpn_gateway(vpn_gateway_id)

Delete a Vpn Gateway.

Parameters:vpn_gateway_id (str) – The ID of the vpn_gateway to be deleted.
Return type:bool
Returns:True if successful
detach_internet_gateway(internet_gateway_id, vpc_id)

Detach an internet gateway from a specific VPC.

Parameters:
  • internet_gateway_id (str) – The ID of the internet gateway to delete.
  • vpc_id (str) – The ID of the VPC to attach to.
Return type:

Bool

Returns:

True if successful

disassociate_route_table(association_id)

Removes an association from a route table. This will cause all subnets that would’ve used this association to now use the main routing association instead.

Parameters:association_id (str) – The ID of the association to disassociate.
Return type:bool
Returns:True if successful
get_all_customer_gateways(customer_gateway_ids=None, filters=None)

Retrieve information about your CustomerGateways. You can filter results to return information only about those CustomerGateways that match your search parameters. Otherwise, all CustomerGateways associated with your account are returned.

Parameters:
  • customer_gateway_ids (list) – A list of strings with the desired CustomerGateway ID’s
  • filters (list of tuples) –

    A list of tuples containing filters. Each tuple consists of a filter key and a filter value. Possible filter keys are:

    • state, the state of the CustomerGateway (pending,available,deleting,deleted)
    • type, the type of customer gateway (ipsec.1)
    • ipAddress the IP address of customer gateway’s internet-routable external inteface
Return type:

list

Returns:

A list of boto.vpc.customergateway.CustomerGateway

get_all_dhcp_options(dhcp_options_ids=None)

Retrieve information about your DhcpOptions.

Parameters:dhcp_options_ids (list) – A list of strings with the desired DhcpOption ID’s
Return type:list
Returns:A list of boto.vpc.dhcpoptions.DhcpOptions
get_all_internet_gateways(internet_gateway_ids=None, filters=None)

Get a list of internet gateways. You can filter results to return information about only those gateways that you’re interested in.

Parameters:
  • internet_gateway_ids (list) – A list of strings with the desired gateway IDs.
  • filters (list of tuples) – A list of tuples containing filters. Each tuple consists of a filter key and a filter value.
get_all_route_tables(route_table_ids=None, filters=None)

Retrieve information about your routing tables. You can filter results to return information only about those route tables that match your search parameters. Otherwise, all route tables associated with your account are returned.

Parameters:
  • route_table_ids (list) – A list of strings with the desired route table IDs.
  • filters (list of tuples) – A list of tuples containing filters. Each tuple consists of a filter key and a filter value.
Return type:

list

Returns:

A list of boto.vpc.routetable.RouteTable

get_all_subnets(subnet_ids=None, filters=None)

Retrieve information about your Subnets. You can filter results to return information only about those Subnets that match your search parameters. Otherwise, all Subnets associated with your account are returned.

Parameters:
  • subnet_ids (list) – A list of strings with the desired Subnet ID’s
  • filters (list of tuples) –

    A list of tuples containing filters. Each tuple consists of a filter key and a filter value. Possible filter keys are:

    • state, the state of the Subnet (pending,available)
    • vpdId, the ID of teh VPC the subnet is in.
    • cidrBlock, CIDR block of the subnet
    • availabilityZone, the Availability Zone the subnet is in.
Return type:

list

Returns:

A list of boto.vpc.subnet.Subnet

get_all_vpcs(vpc_ids=None, filters=None)

Retrieve information about your VPCs. You can filter results to return information only about those VPCs that match your search parameters. Otherwise, all VPCs associated with your account are returned.

Parameters:
  • vpc_ids (list) – A list of strings with the desired VPC ID’s
  • filters (list of tuples) –

    A list of tuples containing filters. Each tuple consists of a filter key and a filter value. Possible filter keys are:

    • state, the state of the VPC (pending or available)
    • cidrBlock, CIDR block of the VPC
    • dhcpOptionsId, the ID of a set of DHCP options
Return type:

list

Returns:

A list of boto.vpc.vpc.VPC

get_all_vpn_connections(vpn_connection_ids=None, filters=None)

Retrieve information about your VPN_CONNECTIONs. You can filter results to return information only about those VPN_CONNECTIONs that match your search parameters. Otherwise, all VPN_CONNECTIONs associated with your account are returned.

Parameters:
  • vpn_connection_ids (list) – A list of strings with the desired VPN_CONNECTION ID’s
  • filters (list of tuples) –

    A list of tuples containing filters. Each tuple consists of a filter key and a filter value. Possible filter keys are:

    • state, the state of the VPN_CONNECTION pending,available,deleting,deleted
    • type, the type of connection, currently ‘ipsec.1’
    • customerGatewayId, the ID of the customer gateway associated with the VPN
    • vpnGatewayId, the ID of the VPN gateway associated with the VPN connection
Return type:

list

Returns:

A list of boto.vpn_connection.vpnconnection.VpnConnection

get_all_vpn_gateways(vpn_gateway_ids=None, filters=None)

Retrieve information about your VpnGateways. You can filter results to return information only about those VpnGateways that match your search parameters. Otherwise, all VpnGateways associated with your account are returned.

Parameters:
  • vpn_gateway_ids (list) – A list of strings with the desired VpnGateway ID’s
  • filters (list of tuples) –

    A list of tuples containing filters. Each tuple consists of a filter key and a filter value. Possible filter keys are:

    • state, the state of the VpnGateway (pending,available,deleting,deleted)
    • type, the type of customer gateway (ipsec.1)
    • availabilityZone, the Availability zone the VPN gateway is in.
Return type:

list

Returns:

A list of boto.vpc.customergateway.VpnGateway

boto.vpc.customergateway

Represents a Customer Gateway

class boto.vpc.customergateway.CustomerGateway(connection=None)
endElement(name, value, connection)

boto.vpc.dhcpoptions

Represents a DHCP Options set

class boto.vpc.dhcpoptions.DhcpConfigSet
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.dhcpoptions.DhcpOptions(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.dhcpoptions.DhcpValueSet
endElement(name, value, connection)
startElement(name, attrs, connection)

boto.vpc.subnet

Represents a Subnet

class boto.vpc.subnet.Subnet(connection=None)
endElement(name, value, connection)

boto.vpc.vpc

Represents a Virtual Private Cloud.

class boto.vpc.vpc.VPC(connection=None)
delete()
endElement(name, value, connection)

boto.vpc.vpnconnection

Represents a VPN Connectionn

class boto.vpc.vpnconnection.VpnConnection(connection=None)
delete()
endElement(name, value, connection)

boto.vpc.vpngateway

Represents a Vpn Gateway

class boto.vpc.vpngateway.Attachment(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.vpngateway.VpnGateway(connection=None)
attach(vpc_id)
endElement(name, value, connection)
startElement(name, attrs, connection)