Manage your subnets
Creating a new VPC subnet
- CLI
- UI
- Terraform
Use the networking vpc-subnets create command to create a new VPC subnet. Optionally, you may use the nat-gateway-enabled flag to enable NAT Gateways.
crusoe networking vpc-subnets create \
--name my-new-vpc-subnet \
--location us-east1-a
--vpc-network-id <uuid-of-vpc-network>
--cidr 10.10.0.0/16
--nat-gateway-enabled true
To create a VPC subnet via the console:
- From the console, select Networking > VPC Subnets in the left nav.
- Click Create VPC Subnet.
- Input a name and CIDR range for the VPC Subnet.
- Select the location and VPC Network in which you would like to create the VPC Subnet.
- (Optional) Use the Enable NAT Gateway toggle to provision your VPC Subnet with a NAT Gateway.
- Click Create.
To create a VPC subnet using the Crusoe Terraform provider, you can use the following code snippet. The snippet creates a new VPC network, and then creates a new VPC subnet in the created. This example also creates a subnet with a NAT Gateway.
terraform {
required_providers {
crusoe = {
source = "registry.terraform.io/crusoecloud/crusoe"
}
}
}
resource "crusoe_vpc_network" "my_vpc_network" {
name = "my-new-network"
cidr = "10.0.0.0/8"
}
resource "crusoe_vpc_subnet" "my_vpc_subnet" {
name = "my-new-subnet"
cidr = "10.0.0.0/16"
location = "us-northcentral1-a"
network = crusoe_vpc_network.my_vpc_network.id
nat_gateway_enabled = true
}
"name", "cidr", "location", and "network" are required arguments for the VPC subnet resource in the Crusoe Terraform provider.
Viewing all VPC subnets
- CLI
- UI
- Terraform
Use the networking vpc-subnets list commands to list existing subnets.
crusoe networking vpc-subnets list
To view subnets via the console:
- From the console, select Networking > VPC Subnets in the left nav.
- Click on a subnet to view additional details.
To list existing VPC subnets using Terraform, the following code snippet can be used to populate a Terraform data source using the Crusoe Terraform provider.
# list vpc subnets
data "crusoe_vpc_subnets" "subnets" {}
output "crusoe_vpc_subnets" {
value = data.crusoe_vpc_subnets.subnets
}
Update an existing VPC subnet
- CLI
- UI
- Terraform
Non-default VPC subnets can be updated in the CLI using the networking vpc-subnets update <id> command. You may update the name, or enable / disable NAT Gateways on the subnet.
crusoe networking vpc-subnets update \
--name my-new-vpc-subnet \
--nat-gateway-enabled true/false
To update an existing non-default VPC subnet via the console:
- From the console, select Networking > VPC Subnets in the left nav.
- Navigate to the row of the VPC subnet you want to update.
- Click the pencil icon on the far right side of the row.
- Edit the fields you want to modify.
- Click Update to save your changes.
To update an existing VPC subnet using the Crusoe Terraform provider, you can change the fields of an existing VPC subnet resource and run terraform apply. The Crusoe Terraform provider will apply the changes to the VPC subnet.
terraform {
required_providers {
crusoe = {
source = "registry.terraform.io/crusoecloud/crusoe"
}
}
}
...
resource "crusoe_vpc_subnet" "my_vpc_subnet" {
name = "my-new-subnet" -> "my-new-name"
cidr = "10.0.0.0/16"
location = "us-northcentral1-a"
network = crusoe_vpc_network.my_vpc_network.id
}
Currently, only the "name" of the VPC subnet can be updated. Changes to the "cidr", "location", or "network" of the VPC subnet will force a re-creation of the VPC subnet (deletion and then creation of a new subnet)
Deleting a VPC subnet
Warning: deleting a VPC subnet is a permanant action that will require re-creation of the subnet to recover.
- CLI
- UI
- Terraform
VPC subnets can be deleted in the CLI using the networking vpc-subnets delete <id> command.
To delete a VPC subnet via the console:
- From the console, select Networking > VPC Subnets in the left nav.
- Navigate to the row of the VPC Subnet you want to delete.
- Click the trash can icon on the far right side of the row.
- Click Confirm.
A VPC subnet can be deleted by using the terraform destroy command provided by the Terraform CLI tool.
If you are having issues working with your VPC subnets, please contact support.