Note

You are viewing the documentation for an older version of boto (boto2).

Boto3, the next version of Boto, is now stable and recommended for general use. It can be used side-by-side with Boto in the same project, so it is easy to start using Boto3 in your existing projects as well as new projects. Going forward, API updates and all new feature work will be focused on Boto3.

For more information, see the documentation for boto3.

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, validate_certs=True, profile_name=None)

Init method to create a new connection to EC2.

accept_vpc_peering_connection(vpc_peering_connection_id, dry_run=False)

Acceptss a VPC peering connection request. The VPC peering connection must be in the pending-acceptance state.

Parameters:vpc_peering_connection_id (str) – The ID of the VPC peering connection.
Return type:Accepted VpcPeeringConnection
Returns:A boto.vpc.vpc_peering_connection.VpcPeeringConnection object
associate_dhcp_options(dhcp_options_id, vpc_id, dry_run=False)

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.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

associate_network_acl(network_acl_id, subnet_id)

Associates a network acl with a specific subnet.

Parameters:
  • network_acl_id (str) – The ID of the network ACL to associate.
  • subnet_id (str) – The ID of the subnet to associate with.
Return type:

str

Returns:

The ID of the association created

associate_route_table(route_table_id, subnet_id, dry_run=False)

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.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

str

Returns:

The ID of the association created

Links an EC2-Classic instance to a ClassicLink-enabled VPC through one or more of the VPC’s security groups. You cannot link an EC2-Classic instance to more than one VPC at a time. You can only link an instance that’s in the running state. An instance is automatically unlinked from a VPC when it’s stopped. You can link it to the VPC again when you restart it.

After you’ve linked an instance, you cannot change the VPC security groups that are associated with it. To change the security groups, you must first unlink the instance, and then link it again.

Linking your instance to a VPC is sometimes referred to as attaching your instance.

Parameters:
  • vpc_id (str) – The ID of a ClassicLink-enabled VPC.
  • instance_is – The ID of a ClassicLink-enabled VPC.
  • groups – The ID of one or more of the VPC’s security groups. You cannot specify security groups from a different VPC. The members of the list can be boto.ec2.securitygroup.SecurityGroup objects or strings of the id’s of the security groups.
  • dry_run (bool) – Set to True if the operation should not actually run.
Tye groups:

list

Return type:

bool

Returns:

True if successful

attach_internet_gateway(internet_gateway_id, vpc_id, dry_run=False)

Attach an internet gateway to a specific VPC.

Parameters:
  • internet_gateway_id (str) – The ID of the internet gateway to attach.
  • vpc_id (str) – The ID of the VPC to attach to.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

Bool

Returns:

True if successful

attach_vpn_gateway(vpn_gateway_id, vpc_id, dry_run=False)

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.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

An attachment

Returns:

a boto.vpc.vpngateway.Attachment

create_customer_gateway(type, ip_address, bgp_asn, dry_run=False)

Create a new Customer Gateway

Parameters:
  • type (str) – Type of VPN Connection. Only valid value currently is ‘ipsec.1’
  • ip_address (str) – Internet-routable IP address for customer’s gateway. Must be a static address.
  • bgp_asn (int) – Customer gateway’s Border Gateway Protocol (BGP) Autonomous System Number (ASN)
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

The newly created CustomerGateway

Returns:

A boto.vpc.customergateway.CustomerGateway object

create_dhcp_options(domain_name=None, domain_name_servers=None, ntp_servers=None, netbios_name_servers=None, netbios_node_type=None, dry_run=False)

Create a new DhcpOption

This corresponds to http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateDhcpOptions.html

Parameters:
  • domain_name (str) – A domain name of your choice (for example, example.com)
  • domain_name_servers (list of strings) – The IP address of a domain name server. You can specify up to four addresses.
  • ntp_servers (list of strings) – The IP address of a Network Time Protocol (NTP) server. You can specify up to four addresses.
  • netbios_name_servers (list of strings) – The IP address of a NetBIOS name server. You can specify up to four addresses.
  • netbios_node_type (str) – The NetBIOS node type (1, 2, 4, or 8). For more information about the values, see RFC 2132. We recommend you only use 2 at this time (broadcast and multicast are currently not supported).
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

The newly created DhcpOption

Returns:

A boto.vpc.customergateway.DhcpOption object

create_internet_gateway(dry_run=False)

Creates an internet gateway for VPC.

Parameters:dry_run (bool) – Set to True if the operation should not actually run.
Return type:Newly created internet gateway.
Returns:boto.vpc.internetgateway.InternetGateway
create_network_acl(vpc_id)

Creates a new network ACL.

Parameters:vpc_id (str) – The VPC ID to associate this network ACL with.
Return type:The newly created network ACL
Returns:A boto.vpc.networkacl.NetworkAcl object
create_network_acl_entry(network_acl_id, rule_number, protocol, rule_action, cidr_block, egress=None, icmp_code=None, icmp_type=None, port_range_from=None, port_range_to=None)

Creates a new network ACL entry in a network ACL within a VPC.

Parameters:
  • network_acl_id (str) – The ID of the network ACL for this network ACL entry.
  • rule_number (int) – The rule number to assign to the entry (for example, 100).
  • protocol (int) – Valid values: -1 or a protocol number

(http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)

Parameters:
  • rule_action (str) – Indicates whether to allow or deny traffic that matches the rule.
  • cidr_block (str) – The CIDR range to allow or deny, in CIDR notation (for example,

172.16.0.0/24).

Parameters:egress (bool) – Indicates whether this rule applies to egress traffic from the subnet (true)

or ingress traffic to the subnet (false).

Parameters:
  • icmp_type (int) – For the ICMP protocol, the ICMP type. You can use -1 to specify all ICMP types.
  • icmp_code (int) – For the ICMP protocol, the ICMP code. You can use -1 to specify

all ICMP codes for the given ICMP type.

Parameters:
  • port_range_from (int) – The first port in the range.
  • port_range_to (int) – The last port in the range.
Return type:

bool

Returns:

True if successful

create_route(route_table_id, destination_cidr_block, gateway_id=None, instance_id=None, interface_id=None, vpc_peering_connection_id=None, dry_run=False)

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.
  • interface_id (str) – Allows routing to network interface attachments.
  • vpc_peering_connection_id (str) – Allows routing to VPC peering connection.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

create_route_table(vpc_id, dry_run=False)

Creates a new route table.

Parameters:
  • vpc_id (str) – The VPC ID to associate this route table with.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

The newly created route table

Returns:

A boto.vpc.routetable.RouteTable object

create_subnet(vpc_id, cidr_block, availability_zone=None, dry_run=False)

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
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

The newly created Subnet

Returns:

A boto.vpc.customergateway.Subnet object

create_vpc(cidr_block, instance_tenancy=None, dry_run=False)

Create a new Virtual Private Cloud.

Parameters:
  • cidr_block (str) – A valid CIDR block
  • instance_tenancy (str) – The supported tenancy options for instances launched into the VPC. Valid values are ‘default’ and ‘dedicated’.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

The newly created VPC

Returns:

A boto.vpc.vpc.VPC object

create_vpc_peering_connection(vpc_id, peer_vpc_id, peer_owner_id=None, dry_run=False)

Create a new VPN Peering connection.

Parameters:
  • vpc_id (str) – The ID of the requester VPC.
  • vpc_peer_id – The ID of the VPC with which you are creating the peering connection.
  • peer_owner_id (str) – The AWS account ID of the owner of the peer VPC.
Return type:

The newly created VpcPeeringConnection

Returns:

A boto.vpc.vpc_peering_connection.VpcPeeringConnection object

create_vpn_connection(type, customer_gateway_id, vpn_gateway_id, static_routes_only=None, dry_run=False)

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.
  • static_routes_only (bool) – Indicates whether the VPN connection

requires static routes. If you are creating a VPN connection for a device that does not support BGP, you must specify true.

Parameters:dry_run (bool) – Set to True if the operation should not actually run.
Return type:The newly created VpnConnection
Returns:A boto.vpc.vpnconnection.VpnConnection object
create_vpn_connection_route(destination_cidr_block, vpn_connection_id, dry_run=False)

Creates a new static route associated with a VPN connection between an existing virtual private gateway and a VPN customer gateway. The static route allows traffic to be routed from the virtual private gateway to the VPN customer gateway.

Parameters:
  • destination_cidr_block (str) – The CIDR block associated with the local subnet of the customer data center.
  • vpn_connection_id (str) – The ID of the VPN connection.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

create_vpn_gateway(type, availability_zone=None, dry_run=False)

Create a new Vpn Gateway

Parameters:
  • type (str) – Type of VPN Connection. Only valid value currently is ‘ipsec.1’
  • availability_zone (str) – The Availability Zone where you want the VPN gateway.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

The newly created VpnGateway

Returns:

A boto.vpc.vpngateway.VpnGateway object

delete_customer_gateway(customer_gateway_id, dry_run=False)

Delete a Customer Gateway.

Parameters:
  • customer_gateway_id (str) – The ID of the customer_gateway to be deleted.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

delete_dhcp_options(dhcp_options_id, dry_run=False)

Delete a DHCP Options

Parameters:
  • dhcp_options_id (str) – The ID of the DHCP Options to be deleted.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

delete_internet_gateway(internet_gateway_id, dry_run=False)

Deletes an internet gateway from the VPC.

Parameters:
  • internet_gateway_id (str) – The ID of the internet gateway to delete.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

Bool

Returns:

True if successful

delete_network_acl(network_acl_id)

Delete a network ACL

Parameters:network_acl_id (str) – The ID of the network_acl to delete.
Return type:bool
Returns:True if successful
delete_network_acl_entry(network_acl_id, rule_number, egress=None)

Deletes a network ACL entry from a network ACL within a VPC.

Parameters:
  • network_acl_id (str) – The ID of the network ACL with the network ACL entry.
  • rule_number (int) – The rule number for the entry to delete.
  • egress (bool) – Specifies whether the rule to delete is an egress rule (true)

or ingress rule (false).

Return type:bool
Returns:True if successful
delete_route(route_table_id, destination_cidr_block, dry_run=False)

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.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

delete_route_table(route_table_id, dry_run=False)

Delete a route table.

Parameters:
  • route_table_id (str) – The ID of the route table to delete.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

delete_subnet(subnet_id, dry_run=False)

Delete a subnet.

Parameters:
  • subnet_id (str) – The ID of the subnet to be deleted.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

delete_vpc(vpc_id, dry_run=False)

Delete a Virtual Private Cloud.

Parameters:
  • vpc_id (str) – The ID of the vpc to be deleted.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

delete_vpc_peering_connection(vpc_peering_connection_id, dry_run=False)

Deletes a VPC peering connection. Either the owner of the requester VPC or the owner of the peer VPC can delete the VPC peering connection if it’s in the active state. The owner of the requester VPC can delete a VPC peering connection in the pending-acceptance state.

Parameters:vpc_peering_connection_id (str) – The ID of the VPC peering connection.
Return type:bool
Returns:True if successful
delete_vpn_connection(vpn_connection_id, dry_run=False)

Delete a VPN Connection.

Parameters:
  • vpn_connection_id (str) – The ID of the vpn_connection to be deleted.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

delete_vpn_connection_route(destination_cidr_block, vpn_connection_id, dry_run=False)

Deletes a static route associated with a VPN connection between an existing virtual private gateway and a VPN customer gateway. The static route allows traffic to be routed from the virtual private gateway to the VPN customer gateway.

Parameters:
  • destination_cidr_block (str) – The CIDR block associated with the local subnet of the customer data center.
  • vpn_connection_id (str) – The ID of the VPN connection.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

delete_vpn_gateway(vpn_gateway_id, dry_run=False)

Delete a Vpn Gateway.

Parameters:
  • vpn_gateway_id (str) – The ID of the vpn_gateway to be deleted.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

Unlinks a linked EC2-Classic instance from a VPC. After the instance has been unlinked, the VPC security groups are no longer associated with it. An instance is automatically unlinked from a VPC when it’s stopped.

Parameters:
  • vpc_id (str) – The ID of the instance to unlink from the VPC.
  • instance_is – The ID of the VPC to which the instance is linked.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

detach_internet_gateway(internet_gateway_id, vpc_id, dry_run=False)

Detach an internet gateway from a specific VPC.

Parameters:
  • internet_gateway_id (str) – The ID of the internet gateway to detach.
  • vpc_id (str) – The ID of the VPC to attach to.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

Bool

Returns:

True if successful

detach_vpn_gateway(vpn_gateway_id, vpc_id, dry_run=False)

Detaches a VPN gateway from a VPC.

Parameters:
  • vpn_gateway_id (str) – The ID of the vpn_gateway to detach
  • vpc_id (str) – The ID of the VPC you want to detach the gateway from.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

disable_vgw_route_propagation(route_table_id, gateway_id, dry_run=False)

Disables a virtual private gateway (VGW) from propagating routes to the routing tables of an Amazon VPC.

Parameters:
  • route_table_id (str) – The ID of the routing table.
  • gateway_id (str) – The ID of the virtual private gateway.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

Disables ClassicLink for a VPC. You cannot disable ClassicLink for a VPC that has EC2-Classic instances linked to it.

Parameters:
  • vpc_id (str) – The ID of the VPC.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

disassociate_network_acl(subnet_id, vpc_id=None)

Figures out what the default ACL is for the VPC, and associates current network ACL with the default.

Parameters:
  • subnet_id (str) – The ID of the subnet to which the ACL belongs.
  • vpc_id (str) – The ID of the VPC to which the ACL/subnet belongs. Queries EC2 if omitted.
Return type:

str

Returns:

The ID of the association created

disassociate_route_table(association_id, dry_run=False)

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.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

enable_vgw_route_propagation(route_table_id, gateway_id, dry_run=False)

Enables a virtual private gateway (VGW) to propagate routes to the routing tables of an Amazon VPC.

Parameters:
  • route_table_id (str) – The ID of the routing table.
  • gateway_id (str) – The ID of the virtual private gateway.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

Enables a VPC for ClassicLink. You can then link EC2-Classic instances to your ClassicLink-enabled VPC to allow communication over private IP addresses. You cannot enable your VPC for ClassicLink if any of your VPC’s route tables have existing routes for address ranges within the 10.0.0.0/8 IP address range, excluding local routes for VPCs in the 10.0.0.0/16 and 10.1.0.0/16 IP address ranges.

Parameters:
  • vpc_id (str) – The ID of the VPC.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

Describes the ClassicLink status of one or more VPCs.

Parameters:
  • vpc_ids (list) – A list of strings with the desired VPC ID’s
  • dry_run (bool) – Set to True if the operation should not actually run.
  • filters (list of tuples or dict) – A list of tuples or dict containing filters. Each tuple or dict item consists of a filter key and a filter value.
Return type:

list

Returns:

A list of boto.vpc.vpc.VPC

get_all_customer_gateways(customer_gateway_ids=None, filters=None, dry_run=False)

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 or dict) –

    A list of tuples or dict containing filters. Each tuple or dict item 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
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

list

Returns:

A list of boto.vpc.customergateway.CustomerGateway

get_all_dhcp_options(dhcp_options_ids=None, filters=None, dry_run=False)

Retrieve information about your DhcpOptions.

Parameters:
  • dhcp_options_ids (list) – A list of strings with the desired DhcpOption ID’s
  • filters (list of tuples or dict) – A list of tuples or dict containing filters. Each tuple or dict item consists of a filter key and a filter value.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

list

Returns:

A list of boto.vpc.dhcpoptions.DhcpOptions

get_all_internet_gateways(internet_gateway_ids=None, filters=None, dry_run=False)

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 or dict) – A list of tuples or dict containing filters. Each tuple or dict item consists of a filter key and a filter value.
  • dry_run (bool) – Set to True if the operation should not actually run.
get_all_network_acls(network_acl_ids=None, filters=None)

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

Parameters:
  • network_acl_ids (list) – A list of strings with the desired network ACL IDs.
  • filters (list of tuples or dict) – A list of tuples or dict containing filters. Each tuple or dict item consists of a filter key and a filter value.
Return type:

list

Returns:

A list of boto.vpc.networkacl.NetworkAcl

get_all_route_tables(route_table_ids=None, filters=None, dry_run=False)

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 or dict) – A list of tuples or dict containing filters. Each tuple or dict item consists of a filter key and a filter value.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

list

Returns:

A list of boto.vpc.routetable.RouteTable

get_all_subnets(subnet_ids=None, filters=None, dry_run=False)

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 or dict) –

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

    • state, a list of states of the Subnet (pending,available)
    • vpcId, a list of IDs of the VPC that the subnet is in.
    • cidrBlock, a list of CIDR blocks of the subnet
    • availabilityZone, list of the Availability Zones the subnet is in.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

list

Returns:

A list of boto.vpc.subnet.Subnet

get_all_vpc_peering_connections(vpc_peering_connection_ids=None, filters=None, dry_run=False)

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

Parameters:
  • vpc_peering_connection_ids (list) – A list of strings with the desired VPC peering 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:

    • accepter-vpc-info.cidr-block - The CIDR block of the peer VPC.
    • accepter-vpc-info.owner-id - The AWS account ID of the owner
      of the peer VPC.
    • accepter-vpc-info.vpc-id - The ID of the peer VPC.
    • expiration-time - The expiration date and time for the VPC
      peering connection.
    • requester-vpc-info.cidr-block - The CIDR block of the
      requester’s VPC.
    • requester-vpc-info.owner-id - The AWS account ID of the
      owner of the requester VPC.
    • requester-vpc-info.vpc-id - The ID of the requester VPC.
    • status-code - The status of the VPC peering connection.
    • status-message - A message that provides more information
      about the status of the VPC peering connection, if applicable.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

list

Returns:

A list of boto.vpc.vpc.VPC

get_all_vpcs(vpc_ids=None, filters=None, dry_run=False)

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 or dict) –

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

    • state - a list of states of the VPC (pending or available)
    • cidrBlock - a list CIDR blocks of the VPC
    • dhcpOptionsId - a list of IDs of a set of DHCP options
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

list

Returns:

A list of boto.vpc.vpc.VPC

get_all_vpn_connections(vpn_connection_ids=None, filters=None, dry_run=False)

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 or dict) –

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

    • state, a list of states of the VPN_CONNECTION pending,available,deleting,deleted
    • type, a list of types of connection, currently ‘ipsec.1’
    • customerGatewayId, a list of IDs of the customer gateway associated with the VPN
    • vpnGatewayId, a list of IDs of the VPN gateway associated with the VPN connection
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

list

Returns:

A list of boto.vpn_connection.vpnconnection.VpnConnection

get_all_vpn_gateways(vpn_gateway_ids=None, filters=None, dry_run=False)

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 or dict) –

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

    • state, a list of states of the VpnGateway (pending,available,deleting,deleted)
    • type, a list types of customer gateway (ipsec.1)
    • availabilityZone, a list of Availability zones the VPN gateway is in.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

list

Returns:

A list of boto.vpc.customergateway.VpnGateway

modify_vpc_attribute(vpc_id, enable_dns_support=None, enable_dns_hostnames=None, dry_run=False)

Modifies the specified attribute of the specified VPC. You can only modify one attribute at a time.

Parameters:
  • vpc_id (str) – The ID of the vpc to be deleted.
  • enable_dns_support (bool) – Specifies whether the DNS server provided by Amazon is enabled for the VPC.
  • enable_dns_hostnames (bool) – Specifies whether DNS hostnames are provided for the instances launched in this VPC. You can only set this attribute to true if EnableDnsSupport is also true.
  • dry_run (bool) – Set to True if the operation should not actually run.
reject_vpc_peering_connection(vpc_peering_connection_id, dry_run=False)

Rejects a VPC peering connection request. The VPC peering connection must be in the pending-acceptance state.

Parameters:vpc_peering_connection_id (str) – The ID of the VPC peering connection.
Return type:bool
Returns:True if successful
replace_network_acl_entry(network_acl_id, rule_number, protocol, rule_action, cidr_block, egress=None, icmp_code=None, icmp_type=None, port_range_from=None, port_range_to=None)

Creates a new network ACL entry in a network ACL within a VPC.

Parameters:
  • network_acl_id (str) – The ID of the network ACL for the id you want to replace
  • rule_number (int) – The rule number that you want to replace(for example, 100).
  • protocol (int) – Valid values: -1 or a protocol number

(http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)

Parameters:
  • rule_action (str) – Indicates whether to allow or deny traffic that matches the rule.
  • cidr_block (str) – The CIDR range to allow or deny, in CIDR notation (for example,

172.16.0.0/24).

Parameters:egress (bool) – Indicates whether this rule applies to egress traffic from the subnet (true)

or ingress traffic to the subnet (false).

Parameters:
  • icmp_type (int) – For the ICMP protocol, the ICMP type. You can use -1 to specify all ICMP types.
  • icmp_code (int) – For the ICMP protocol, the ICMP code. You can use -1 to specify

all ICMP codes for the given ICMP type.

Parameters:
  • port_range_from (int) – The first port in the range.
  • port_range_to (int) – The last port in the range.
Return type:

bool

Returns:

True if successful

replace_route(route_table_id, destination_cidr_block, gateway_id=None, instance_id=None, interface_id=None, vpc_peering_connection_id=None, dry_run=False)

Replaces an existing route within a route table in a 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.
  • interface_id (str) – Allows routing to network interface attachments.
  • vpc_peering_connection_id (str) – Allows routing to VPC peering connection.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

replace_route_table_assocation(association_id, route_table_id, dry_run=False)

Replaces a route association with a new route table. This can be used to replace the ‘main’ route table by using the main route table association instead of the more common subnet type association.

NOTE: It may be better to use replace_route_table_association_with_assoc instead of this function; this function does not return the new association ID. This function is retained for backwards compatibility.

Parameters:
  • association_id (str) – The ID of the existing association to replace.
  • route_table_id (str) – The route table to ID to be used in the association.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

replace_route_table_association_with_assoc(association_id, route_table_id, dry_run=False)

Replaces a route association with a new route table. This can be used to replace the ‘main’ route table by using the main route table association instead of the more common subnet type association. Returns the new association ID.

Parameters:
  • association_id (str) – The ID of the existing association to replace.
  • route_table_id (str) – The route table to ID to be used in the association.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

str

Returns:

New association ID

boto.vpc.connect_to_region(region_name, **kw_params)

Given a valid region name, return a boto.vpc.VPCConnection. Any additional parameters after the region_name are passed on to the connect method of the region object.

Type:str
Parameters:region_name – The name of the region to connect to.
Return type:boto.vpc.VPCConnection or None
Returns:A connection to the given region, or None if an invalid region name is given
boto.vpc.regions(**kw_params)

Get all available regions for the EC2 service. You may pass any of the arguments accepted by the VPCConnection object’s constructor as keyword arguments and they will be passed along to the VPCConnection object.

Return type:list
Returns:A list of boto.ec2.regioninfo.RegionInfo

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.internetgateway

Represents an Internet Gateway

class boto.vpc.internetgateway.InternetGateway(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.internetgateway.InternetGatewayAttachment(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)

boto.vpc.routetable

Represents a Route Table

class boto.vpc.routetable.Route(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.routetable.RouteAssociation(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.routetable.RouteTable(connection=None)
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)

Represents a VPC.

Variables:
  • id – The unique ID of the VPC.
  • dhcp_options_id – The ID of the set of DHCP options you’ve associated with the VPC (or default if the default options are associated with the VPC).
  • state – The current state of the VPC.
  • cidr_block – The CIDR block for the VPC.
  • is_default – Indicates whether the VPC is the default VPC.
  • instance_tenancy – The allowed tenancy of instances launched into the VPC.
  • classic_link_enabled – Indicates whether ClassicLink is enabled.
attach_classic_instance(instance_id, groups, dry_run=False)

Links an EC2-Classic instance to a ClassicLink-enabled VPC through one or more of the VPC’s security groups. You cannot link an EC2-Classic instance to more than one VPC at a time. You can only link an instance that’s in the running state. An instance is automatically unlinked from a VPC when it’s stopped. You can link it to the VPC again when you restart it.

After you’ve linked an instance, you cannot change the VPC security groups that are associated with it. To change the security groups, you must first unlink the instance, and then link it again.

Linking your instance to a VPC is sometimes referred to as attaching your instance.

Parameters:
  • instance_is – The ID of a ClassicLink-enabled VPC.
  • groups – The ID of one or more of the VPC’s security groups. You cannot specify security groups from a different VPC. The members of the list can be boto.ec2.securitygroup.SecurityGroup objects or strings of the id’s of the security groups.
  • dry_run (bool) – Set to True if the operation should not actually run.
Tye groups:

list

Return type:

bool

Returns:

True if successful

delete()
detach_classic_instance(instance_id, dry_run=False)

Unlinks a linked EC2-Classic instance from a VPC. After the instance has been unlinked, the VPC security groups are no longer associated with it. An instance is automatically unlinked from a VPC when it’s stopped.

Parameters:
  • instance_is – The ID of the VPC to which the instance is linked.
  • dry_run (bool) – Set to True if the operation should not actually run.
Return type:

bool

Returns:

True if successful

Disables ClassicLink for a VPC. You cannot disable ClassicLink for a VPC that has EC2-Classic instances linked to it.

Parameters:dry_run (bool) – Set to True if the operation should not actually run.
Return type:bool
Returns:True if successful

Enables a VPC for ClassicLink. You can then link EC2-Classic instances to your ClassicLink-enabled VPC to allow communication over private IP addresses. You cannot enable your VPC for ClassicLink if any of your VPC’s route tables have existing routes for address ranges within the 10.0.0.0/8 IP address range, excluding local routes for VPCs in the 10.0.0.0/16 and 10.1.0.0/16 IP address ranges.

Parameters:dry_run (bool) – Set to True if the operation should not actually run.
Return type:bool
Returns:True if successful
endElement(name, value, connection)
update(validate=False, dry_run=False)

Updates instance’s classic_link_enabled attribute

Return type:bool
Returns:self.classic_link_enabled after update has occurred.

boto.vpc.vpnconnection

class boto.vpc.vpnconnection.VpnConnection(connection=None)

Represents a VPN Connection

Variables:
  • id – The ID of the VPN connection.
  • state – The current state of the VPN connection. Valid values: pending | available | deleting | deleted
  • customer_gateway_configuration – The configuration information for the VPN connection’s customer gateway (in the native XML format). This element is always present in the boto.vpc.VPCConnection.create_vpn_connection response; however, it’s present in the boto.vpc.VPCConnection.get_all_vpn_connections response only if the VPN connection is in the pending or available state.
  • type – The type of VPN connection (ipsec.1).
  • customer_gateway_id – The ID of the customer gateway at your end of the VPN connection.
  • vpn_gateway_id – The ID of the virtual private gateway at the AWS side of the VPN connection.
  • tunnels – A list of the vpn tunnels (always 2)
  • options – The option set describing the VPN connection.
  • static_routes – A list of static routes associated with a VPN connection.
delete(dry_run=False)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.vpnconnection.VpnConnectionOptions(static_routes_only=None)

Represents VPN connection options

Variables:static_routes_only – Indicates whether the VPN connection uses static routes only. Static routes must be used for devices that don’t support BGP.
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.vpnconnection.VpnStaticRoute(destination_cidr_block=None, source=None, state=None)

Represents a static route for a VPN connection.

Variables:
  • destination_cidr_block – The CIDR block associated with the local subnet of the customer data center.
  • source – Indicates how the routes were provided.
  • state – The current state of the static route.
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.vpc.vpnconnection.VpnTunnel(outside_ip_address=None, status=None, last_status_change=None, status_message=None, accepted_route_count=None)

Represents telemetry for a VPN tunnel

Variables:
  • outside_ip_address – The Internet-routable IP address of the virtual private gateway’s outside interface.
  • status – The status of the VPN tunnel. Valid values: UP | DOWN
  • last_status_change – The date and time of the last change in status.
  • status_message – If an error occurs, a description of the error.
  • accepted_route_count – The number of accepted routes.
endElement(name, value, connection)
startElement(name, attrs, 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, dry_run=False)
endElement(name, value, connection)
startElement(name, attrs, connection)