Skip to main content

subnets

Creates, updates, deletes, gets or lists a subnets resource.

Overview

Namesubnets
TypeResource
Idlinode.vpcs.subnets

Fields

The following fields are returned by SELECT queries:

A VPC Subnet object.

NameDatatypeDescription
idintegerFilterable, Read-only The unique ID of the VPC Subnet.
createdstring (date-time)Filterable, Read-only The date-time of VPC Subnet creation. (example: 2023-07-11T00:00:00)
ipv4string (ip)IPv4 range in CIDR canonical form. - The range must belong to a private address space as defined in RFC1918. - Allowed prefix lengths: 1-29. - The range must not overlap with 192.168.128.0/17. - The range must not overlap with other Subnets on the same VPC. (example: 10.0.1.0/24)
labelstringFilterable The VPC Subnet's label, for display purposes only. - Must be unique among the VPC's Subnets. - Can only contain ASCII letters, numbers, and hyphens (-). You can't use two consecutive hyphens (--). (example: cool-vpc-subnet)
linodesarrayRead-only An array of Linode IDs assigned to the VPC Subnet. A Linode is assigned to a VPC Subnet if it has a Configuration Profile with a vpc purpose interface with the subnet's subnet_id. Even if the Configuration Profile is not active, meaning the Linode does not have access to the Subnet, the Linode still appears in this array.
updatedstring (date-time)Filterable, Read-only The date-time of the most recent VPC Subnet update. (example: 2023-09-11T00:00:00)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_vpc_subnetselectGet information about a single VPC Subnet.

Learn more...
get_vpc_subnetsselectpage, page_sizeGet information about all VPC Subnets associated with a VPC.

Learn more...
post_vpc_subnetinsertdata__ipv4, data__labelCreate a VPC Subnet.

- The User accessing this operation must have read_write grants to the VPC.
- A successful request triggers a subnet_create event.

Once a VPC Subnet is created, it can be attached to a Linode by assigning the Subnet to one of the Linode's Configuration Profile Interfaces. This step can be accomplished with the following operations:

- Create a Linode
- Create a config profile
- Update a config profile
- Add a configuration profile interface

Learn more...

Learn more...
put_vpc_subnetreplaceUpdate a VPC Subnet.

- The User accessing this operation must have read_write grants to the VPC.
- A successful request triggers a subnet_update event.

Learn more...

Learn more...
delete_vpc_subnetdeleteDelete a single VPC subnet.

The user accessing this operation must have read_write grants to the VPC. A successful request triggers a subnet_delete event.

> 📘
>
> You need to delete all the Configuration Profile Interfaces that this subnet is assigned to before you can delete it. If those interfaces are active, the associated Linode needs to be shut down before they can be removed.

Learn more...

Learn more...

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
pageintegerThe page of a collection to return.
page_sizeintegerThe number of items to return per page.

SELECT examples

Get information about a single VPC Subnet.

Learn more...

SELECT
id,
created,
ipv4,
label,
linodes,
updated
FROM linode.vpcs.subnets;

INSERT examples

Create a VPC Subnet.

- The User accessing this operation must have read_write grants to the VPC.
- A successful request triggers a subnet_create event.

Once a VPC Subnet is created, it can be attached to a Linode by assigning the Subnet to one of the Linode's Configuration Profile Interfaces. This step can be accomplished with the following operations:

- Create a Linode
- Create a config profile
- Update a config profile
- Add a configuration profile interface

Learn more...

Learn more...

INSERT INTO linode.vpcs.subnets (
data__ipv4,
data__label
)
SELECT
'{{ ipv4 }}' --required,
'{{ label }}' --required
RETURNING
id,
created,
ipv4,
label,
linodes,
updated
;

REPLACE examples

Update a VPC Subnet.

- The User accessing this operation must have read_write grants to the VPC.
- A successful request triggers a subnet_update event.

Learn more...

Learn more...

REPLACE linode.vpcs.subnets
SET
data__label = '{{ label }}'
WHERE

RETURNING
id,
created,
ipv4,
label,
linodes,
updated;

DELETE examples

Delete a single VPC subnet.

The user accessing this operation must have read_write grants to the VPC. A successful request triggers a subnet_delete event.

> 📘
>
> You need to delete all the Configuration Profile Interfaces that this subnet is assigned to before you can delete it. If those interfaces are active, the associated Linode needs to be shut down before they can be removed.

Learn more...

Learn more...

DELETE FROM linode.vpcs.subnets;