boto3_vpc

Manage VPCs using boto3.

Renamed from boto_vpc to boto3_vpc and updated to call the refactored boto3_vpc execution module.

Create and destroy VPCs. Be aware that this interacts with Amazon’s services, and so may incur charges.

depends:
  • boto3 >= 1.28.0

  • botocore >= 1.31.0

This module uses boto3, which can be installed via package, or pip.

This module accepts explicit VPC credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More information available here.

If IAM roles are not used you need to specify them either in a pillar file or in the minion’s config file:

vpc.keyid: GKTADJGHEIQSXMKKRBJ08H
vpc.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

It’s also possible to specify key, keyid and region via a profile, either passed in as a dict, or as a string to pull from pillars or minion config:

myprofile:
    keyid: GKTADJGHEIQSXMKKRBJ08H
    key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
    region: us-east-1
Ensure VPC exists:
  boto3_vpc.present:
    - name: myvpc
    - cidr_block: 10.10.11.0/24
    - region: us-east-1

Ensure subnet exists:
  boto3_vpc.subnet_present:
    - name: mysubnet
    - vpc_id: vpc-123456
    - cidr_block: 10.0.0.0/16
    - region: us-east-1
    - profile: myprofile

Added in version 1.0.0.

saltext.boto3.states.boto3_vpc.__virtual__()[source]

Only load if the boto3_vpc execution module is available.

saltext.boto3.states.boto3_vpc.present(name, cidr_block, secondary_cidr_blocks=None, instance_tenancy=None, dns_support=None, dns_hostnames=None, tags=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure a VPC with the supplied properties exists.

Changed in version 1.1.0: Support associating secondary CIDR blocks through secondary_cidr_blocks or backward-compatible list input.

name (str):

Name of the VPC.

cidr_block (str):

The primary VPC CIDR block, e.g. 10.0.0.0/24.

secondary_cidr_blocks (list, optional):

Optional list of additional CIDR blocks to associate to the VPC. For backward compatibility, cidr_block can still be provided as a list where the first entry is primary and the rest are secondary.

instance_tenancy (str, optional):

Tenancy for instances launched in this VPC (default or dedicated).

dns_support (bool, optional):

Whether DNS resolution is supported for the VPC.

dns_hostnames (bool, optional):

Whether instances launched in the VPC receive DNS hostnames.

tags (dict, optional):

Dict of tag key/values to apply. Defaults to None.

region (str, optional):

The AWS region where the VPC exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-present:
  boto3_vpc.present:
    - name: example
    - cidr_block: 10.0.0.0/24
saltext.boto3.states.boto3_vpc.absent(name, tags=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure the named VPC is absent.

name (str):

Name of the VPC.

tags (dict, optional):

Optional tag filter; all tags must match. Defaults to None.

region (str, optional):

The AWS region where the VPC exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-absent:
  boto3_vpc.absent:
    - name: example
saltext.boto3.states.boto3_vpc.dhcp_options_present(name, dhcp_options_id=None, vpc_name=None, vpc_id=None, domain_name=None, domain_name_servers=None, ntp_servers=None, netbios_name_servers=None, netbios_node_type=None, tags=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure a DHCP options set with the given settings exists.

Note

This implementation only sets values during option set creation. It cannot update an existing option set in place.

name (str):

Name of the DHCP options set.

dhcp_options_id (str, optional):

The ID of the DHCP options set. Defaults to None.

vpc_name (str, optional):

The name of the VPC to associate with the DHCP options set. Defaults to None.

vpc_id (str, optional):

The ID of the VPC to associate with the DHCP options set. Defaults to None.

domain_name (str, optional):

The domain name for the DHCP options set. Defaults to None.

domain_name_servers (list, optional):

A list of domain name servers for the DHCP options set. Defaults to None.

ntp_servers (list, optional):

A list of NTP servers for the DHCP options set. Defaults to None.

netbios_name_servers (list, optional):

A list of NetBIOS name servers for the DHCP options set. Defaults to None.

netbios_node_type (int, optional):

The NetBIOS node type for the DHCP options set. Defaults to None.

tags (dict, optional):

Dict of tag key/values to apply. Defaults to None.

region (str, optional):

The AWS region where the DHCP options set exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Changed in version 1.0.1.

Example:

ensure-dhcp-options-present:
  boto3_vpc.dhcp_options_present:
    - name: example
    - cidr_block: 10.0.0.0/24
saltext.boto3.states.boto3_vpc.dhcp_options_absent(name=None, dhcp_options_id=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure a DHCP options set is absent.

name (str):

The name of the DHCP options set.

dhcp_options_id (str, optional):

The ID of the DHCP options set. Defaults to None.

vpc_name (str, optional):

The name of the VPC to associate with the DHCP options set. Defaults to None.

vpc_id (str, optional):

The ID of the VPC to associate with the DHCP options set. Defaults to None.

domain_name (str, optional):

The domain name for the DHCP options set. Defaults to None.

domain_name_servers (list, optional):

A list of domain name servers for the DHCP options set. Defaults to None.

ntp_servers (list, optional):

A list of NTP servers for the DHCP options set. Defaults to None.

netbios_name_servers (list, optional):

A list of NetBIOS name servers for the DHCP options set. Defaults to None.

netbios_node_type (int, optional):

The NetBIOS node type for the DHCP options set. Defaults to None.

tags (dict, optional):

Dict of tag key/values to apply. Defaults to None.

region (str, optional):

The AWS region where the DHCP options set exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-dhcp-options-absent:
  boto3_vpc.dhcp_options_absent:
    - name: example
saltext.boto3.states.boto3_vpc.subnet_present(name, cidr_block, vpc_name=None, vpc_id=None, availability_zone=None, tags=None, region=None, key=None, keyid=None, profile=None, auto_assign_public_ipv4=False)[source]

Ensure a subnet exists.

Note

Route table association is not handled by the boto3_vpc subnet states yet; that will land with the route_table port.

name (str):

Name of the subnet.

cidr_block (str):

The range of IPs for the subnet, in CIDR format.

vpc_name (str, optional):

The name of the VPC the subnet belongs to. Defaults to None.

vpc_id (str, optional):

The ID of the VPC the subnet belongs to. Defaults to None.

availability_zone (str, optional):

Optional AZ to place the subnet in. Defaults to None.

auto_assign_public_ipv4 (bool, optional):

If True, instances launched into this subnet will be assigned a public IPv4 address by default. Defaults to False.

Example:

ensure-subnet-present:
  boto3_vpc.subnet_present:
    - name: example
    - cidr_block: 10.0.0.0/24
    - vpc_name: my-vpc
saltext.boto3.states.boto3_vpc.subnet_absent(name=None, subnet_id=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure a subnet is absent.

name (str):

The name of the subnet.

subnet_id (str, optional):

The ID of the subnet. Defaults to None.

region (str, optional):

The AWS region where the subnet exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-subnet-absent:
  boto3_vpc.subnet_absent:
    - name: example
saltext.boto3.states.boto3_vpc.internet_gateway_present(name, vpc_name=None, vpc_id=None, tags=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure an internet gateway exists.

name (str):

Name of the internet gateway.

vpc_name (str, optional):

Name of the VPC to which the internet gateway should be attached. Defaults to None.

vpc_id (str, optional):

Id of the VPC to which the internet_gateway should be attached. Only one of vpc_name or vpc_id may be provided. Defaults to None.

tags (list, optional):

A list of tags. Defaults to None.

region (str, optional):

The AWS region where the internet gateway exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-internet-gateway-present:
  boto3_vpc.internet_gateway_present:
    - name: example
    - vpc_name: my-vpc
saltext.boto3.states.boto3_vpc.internet_gateway_absent(name, detach=False, region=None, key=None, keyid=None, profile=None)[source]

Ensure the named internet gateway is absent.

name (str):

Name of the internet gateway.

detach (bool, optional):

First detach the internet gateway from a VPC, if attached. Defaults to False.

region (str, optional):

The AWS region where the internet gateway exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-internet-gateway-absent:
  boto3_vpc.internet_gateway_absent:
    - name: example
saltext.boto3.states.boto3_vpc.route_table_present(name, vpc_name=None, vpc_id=None, routes=None, subnet_ids=None, subnet_names=None, tags=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure route table with routes exists and is associated to a VPC.

name (str):

The name of the route table.

vpc_name (str, optional):

The name of the VPC to which the route table belongs. Defaults to None.

vpc_id (str, optional):

The ID of the VPC to which the route table belongs. Defaults to None.

routes (list, optional):

A list of routes to be added to the route table. Defaults to None.

subnet_ids (list, optional):

A list of subnet IDs to be associated with the route table. Defaults to None.

subnet_names (list, optional):

A list of subnet names to be associated with the route table. Defaults to None.

tags (list, optional):

A list of tags to be applied to the route table. Defaults to None.

region (str, optional):

The AWS region where the route table exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

boto3_vpc.route_table_present:
  - name: my_route_table
  - vpc_id: vpc-123456
  - routes:
    - destination_cidr_block: 0.0.0.0/0
      internet_gateway_name: InternetGateway
    - destination_cidr_block: 10.10.11.0/24
      instance_id: i-123456
    - destination_cidr_block: 10.10.12.0/24
      interface_id: eni-123456
  - subnet_names:
    - subnet1
    - subnet2
saltext.boto3.states.boto3_vpc.route_table_absent(name, region=None, key=None, keyid=None, profile=None)[source]

Ensure the named route table is absent.

Changed in version 1.1.0: Disassociate non-main route table associations before deletion.

name (str):

The name of the route table to be removed.

region (str, optional):

The AWS region where the route table exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-route-table-absent:
  boto3_vpc.route_table_absent:
    - name: example
saltext.boto3.states.boto3_vpc.nat_gateway_present(name, subnet_name=None, subnet_id=None, region=None, key=None, keyid=None, profile=None, allocation_id=None)[source]

Ensure a nat gateway exists within the specified subnet.

name (str):

The name of the nat gateway.

subnet_name (str, optional):

The name of the subnet where the nat gateway should exist. Defaults to None.

subnet_id (str, optional):

The ID of the subnet where the nat gateway should exist. Defaults to None.

region (str, optional):

The AWS region where the nat gateway exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

allocation_id (str, optional):

The allocation ID for the nat gateway. Defaults to None.

Example:

boto3_vpc.nat_gateway_present:
  - subnet_name: my-subnet
saltext.boto3.states.boto3_vpc.nat_gateway_absent(name=None, subnet_name=None, subnet_id=None, region=None, key=None, keyid=None, profile=None, wait_for_delete_retries=0)[source]

Ensure the nat gateway in the named subnet is absent.

name (str):

The name of the nat gateway.

subnet_name (str, optional):

The name of the subnet where the nat gateway exists. Defaults to None.

subnet_id (str, optional):

The ID of the subnet where the nat gateway exists. Defaults to None.

region (str, optional):

The AWS region where the nat gateway exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

wait_for_delete_retries (int, optional):

The number of retries to wait for the nat gateway to be deleted. Defaults to 0.

Example:

ensure-nat-gateway-absent:
  boto3_vpc.nat_gateway_absent:
    - name: example
saltext.boto3.states.boto3_vpc.accept_vpc_peering_connection(name=None, conn_id=None, conn_name=None, region=None, key=None, keyid=None, profile=None)[source]

Accept a VPC pending requested peering connection between two VPCs.

name (str):

The name of the VPC peering connection to accept.

conn_id (str, optional):

The ID of the VPC peering connection to accept. Defaults to None.

conn_name (str, optional):

The name of the VPC peering connection to accept. Defaults to None.

region (str, optional):

The AWS region where the VPC peering connection exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

boto3_vpc.accept_vpc_peering_connection:
  - conn_name: salt_peering_connection
saltext.boto3.states.boto3_vpc.request_vpc_peering_connection(name, requester_vpc_id=None, requester_vpc_name=None, peer_vpc_id=None, peer_vpc_name=None, conn_name=None, peer_owner_id=None, peer_region=None, region=None, key=None, keyid=None, profile=None)[source]

Request a VPC peering connection between two VPCs.

name (str):

The name of the VPC peering connection to request.

requester_vpc_id (str, optional):

The ID of the requester VPC. Defaults to None.

requester_vpc_name (str, optional):

The name of the requester VPC. Defaults to None.

peer_vpc_id (str, optional):

The ID of the peer VPC. Defaults to None.

peer_vpc_name (str, optional):

The name of the peer VPC. Defaults to None.

conn_name (str, optional):

The name of the VPC peering connection. Defaults to None.

peer_owner_id (str, optional):

The AWS account ID of the owner of the peer VPC. Defaults to None.

peer_region (str, optional):

The AWS region where the peer VPC exists. Defaults to None.

region (str, optional):

The AWS region where the requester VPC exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

request a vpc peering connection:
  boto3_vpc.request_vpc_peering_connection:
    - requester_vpc_id: vpc-4b3522e
    - peer_vpc_id: vpc-ae83f9ca
    - conn_name: salt_peering_connection
saltext.boto3.states.boto3_vpc.vpc_peering_connection_present(name, requester_vpc_id=None, requester_vpc_name=None, peer_vpc_id=None, peer_vpc_name=None, conn_name=None, peer_owner_id=None, peer_region=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure a VPC peering connection is present.

name (str):

The name of the VPC peering connection to ensure is present.

requester_vpc_id (str, optional):

The ID of the requester VPC. Defaults to None.

requester_vpc_name (str, optional):

The name of the requester VPC. Defaults to None.

peer_vpc_id (str, optional):

The ID of the peer VPC. Defaults to None.

peer_vpc_name (str, optional):

The name of the peer VPC. Defaults to None.

conn_name (str, optional):

The name of the VPC peering connection. Defaults to None.

peer_owner_id (str, optional):

The AWS account ID of the owner of the peer VPC. Defaults to None.

peer_region (str, optional):

The AWS region where the peer VPC exists. Defaults to None.

region (str, optional):

The AWS region where the requester VPC exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-vpc-peering-connection-present:
  boto3_vpc.vpc_peering_connection_present:
    - name: example
    - vpc_name: my-vpc
saltext.boto3.states.boto3_vpc.vpc_peering_connection_absent(name, conn_id=None, conn_name=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure a VPC peering connection is absent.

name (str):

The name of the VPC peering connection to ensure is absent.

conn_id (str, optional):

The ID of the VPC peering connection to ensure is absent. Defaults to None.

conn_name (str, optional):

The name of the VPC peering connection to ensure is absent. Defaults to None.

region (str, optional):

The AWS region where the VPC peering connection exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-vpc-peering-connection-absent:
  boto3_vpc.vpc_peering_connection_absent:
    - name: example
saltext.boto3.states.boto3_vpc.delete_vpc_peering_connection(name, conn_id=None, conn_name=None, region=None, key=None, keyid=None, profile=None)[source]

Delete a VPC peering connection.

name (str):

The name of the VPC peering connection to delete.

conn_id (str, optional):

The ID of the VPC peering connection to delete. Defaults to None.

conn_name (str, optional):

The name of the VPC peering connection to delete. Defaults to None.

region (str, optional):

The AWS region where the VPC peering connection exists. Defaults to None.

key (str, optional):

The AWS access key. Defaults to None.

keyid (str, optional):

The AWS secret key. Defaults to None.

profile (str, optional):

The AWS profile to use. Defaults to None.

Example:

ensure-delete-vpc-peering-connection:
  boto3_vpc.delete_vpc_peering_connection:
    - name: example