Skip to content
0850 554 5439 [email protected]

How can we help?

Search our guides and tutorials, or browse the categories below.

Creating a VPC and subnets (panel, CLI, API, Terraform)

Gyro Cloud Istanbul 16 views Step-by-step guide Last verified: Markdown
What you will learnHow to create a VPC and subnets from the panel, command line, API and Terraform, and the common errors.
Time5 minutes
Who is it forSysadmins and developers.
What you needA Gyro account; for the concept see What is a private network (VPC)?.

1. From the panel

  1. Open Gyro Console → Private networks (VPC) (or open the Private network (VPC) tool on a server's service page).
  2. 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.
  3. 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 named default is created.
  4. 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).

Info

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

bash
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):

bash
gyro vpc subnet delete <vpc-id> <subnet-id>
gyro vpc delete <vpc-id>

3. API

bash
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

hcl
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

Was this helpful?

Thanks for your feedback!

Still Need Help?

Our support team is here around the clock for anything you can't find above.