Creating a VPC and subnets (panel, CLI, API, Terraform)
1. From the panel
- Open Gyro Console → Private networks (VPC) (or open the Private network (VPC) tool on a server's service page).
- Click Create VPC. Enter a name (for example
production) and an IP range (suggested:10.10.0.0/16). Make sure it does not overlap other VPCs you may use later. - Choose a name (for example
app) and size for the first subnet (/24 is suggested, 251 usable addresses). If you leave it empty, a /24 subnet nameddefaultis created. - Click Create. The VPC is ready in a few seconds.
To add a second subnet open the VPC and use Add subnet (for example database, 10.10.2.0/24).
Enter the network address in the CIDR field (10.10.1.0/24). A host address such as 10.10.1.5/24 is rejected.
2. gyro command line
gyro vpc create --name production --cidr 10.10.0.0/16
gyro vpc subnet create <vpc-id> --name database --cidr 10.10.2.0/24
gyro vpc list
gyro vpc get <vpc-id>
gyro vpc subnet list <vpc-id>
To delete (remove attached server NICs and port forwards first; every VPC keeps at least one subnet):
gyro vpc subnet delete <vpc-id> <subnet-id>
gyro vpc delete <vpc-id>
3. API
curl -X POST https://www.gyrohosting.com/api/v1/client/cloud/vpcs \
-H "Authorization: Bearer $GYRO_TOKEN" -H "Content-Type: application/json" \
-d '{"name":"production","cidr":"10.10.0.0/16","subnet":{"name":"app","cidr":"10.10.1.0/24"}}'
curl -X POST https://www.gyrohosting.com/api/v1/client/cloud/vpcs/<vpc-id>/subnets \
-H "Authorization: Bearer $GYRO_TOKEN" -H "Content-Type: application/json" \
-d '{"name":"database","cidr":"10.10.2.0/24"}'
If you omit cidr, a free range is suggested using prefix (default 24). Reading: GET /cloud/vpcs (also returns your limits and the gateway price), GET /cloud/vpcs/{id}.
4. Terraform
resource "gyro_vpc" "main" {
name = "production"
cidr = "10.10.0.0/16"
}
resource "gyro_subnet" "database" {
vpc_id = gyro_vpc.main.id
name = "database"
cidr = "10.10.2.0/24"
}
The VPC comes with the first subnet (default) the API creates; its ID is in the default_subnet_id output. Existing objects can be imported with terraform import (gyro_vpc = ID, gyro_subnet = <vpc-id>/<subnet-id>).
5. Common errors
| Error | Meaning |
|---|---|
reserved_range |
The range is reserved by the platform (such as 10.200/16, 10.42/16); pick another. |
invalid_cidr |
Wrong size or format: VPC /16-/24, subnet /20-/28; enter a network address. |
cidr_overlap |
Two subnets in the same VPC cannot cover the same addresses. |
limit_exceeded / vpc_full |
You reached the VPC or subnet limit; open a support ticket if needed. |
name_taken |
You already have an object with that name. |
vpc_in_use / subnet_in_use |
A server NIC is attached to the VPC/subnet you want to delete; detach it first. |
last_subnet |
The last subnet of a VPC cannot be deleted. |
capacity |
Private network capacity is full right now; try again in a few minutes or open a ticket. |
Next step
Thanks for your feedback!
