Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Virtual Private Cloud
  • Getting started
    • All guides
      • Creating a subnet
      • Deleting a subnet
      • Updating a subnet
      • Getting information about a subnet
      • Moving a subnet between folders
      • Moving a subnet to a different availability zone
      • Viewing a list of used addresses
    • Enabling a software-accelerated network
    • Chart of network connections
    • Viewing operations with resources
  • DDoS Protection
  • Access management
  • Terraform reference
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Examples
  • Changing a subnet using the name flag
  1. Step-by-step guides
  2. Subnet
  3. Updating a subnet

Updating a subnet

Written by
Yandex Cloud
Improved by
Dmitry A.
Updated at May 5, 2025
  • Examples
    • Changing a subnet using the name flag

After creating a subnet, you can change its name, description, and DHCP settings.

Management console
CLI
Terraform
API
  1. In the management console, go to the folder where you need to update a subnet.
  2. In the list of services, select Virtual Private Cloud.
  3. In the left-hand panel, select Subnets.
  4. Click in the row of the subnet you need and select Edit.
  5. Edit as appropriate.
  6. Click Save changes.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. View the description of the CLI command for updating subnet parameters:

    yc vpc subnet update --help
    
  2. Get a list of all subnets in the default folder:

    yc vpc subnet list
    

    Result:

    +----------------------+-----------------------+----------------------+
    |          ID          |         NAME          |         ...          |
    +----------------------+-----------------------+----------------------+
    ...
    | e2l2prrbkbim******** |     test-subnet-1     |         ...          |
    ...
    +----------------------+-----------------------+----------------------+
    
  3. Select the ID or NAME of the subnet you need.

  4. Change the subnet parameters, e.g.:

    yc vpc subnet update e2l2prrbkbim******** \
      --new-name test-subnet-renamed \
      --labels new_label=test_label
    

    Result:

    id: e2l2prrbkbim********
    folder_id: b1g6ci08ma55********
    created_at: "2018-10-24T13:54:10Z"
    name: test-subnet-renamed
    description: My test subnet
    labels:
      new_label: test_label
    network_id: enplom7a98s1********
    zone_id: ru-central1-a
    v4_cidr_blocks:
    - 192.168.0.0/24
    

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

  1. Open the Terraform configuration file and edit the fragment with the subnet description:

    ...
    resource "yandex_vpc_subnet" "lab-subnet-a" {
      name           = "subnet-1"
      description    = "My first subnet"
      v4_cidr_blocks = ["10.2.0.0/16"]
      zone           = "ru-central1-a"
      network_id     = "${yandex_vpc_network.lab-net.id}"
    }
    ...
    

    For more information about the yandex_vpc_subnet resource parameters in Terraform, see the provider documentation.

  2. Check the configuration using this command:

    terraform validate
    

    If the configuration is correct, you will get this message:

    Success! The configuration is valid.
    
  3. Run this command:

    terraform plan
    

    The terminal will display a list of resources with their parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.

  4. Apply the configuration changes:

    terraform apply
    
  5. Confirm the changes: type yes into the terminal and press Enter.

    You can check the subnet update using the management console or this CLI command:

    yc vpc subnet get <subnet_name>
    

To change the subnet, use the update REST API method for the Subnet resource or the SubnetService/Update gRPC API call, and provide the following in the request:

  • ID of the subnet you want to update in the subnetId request parameter.

    To get the subnet ID, use the list REST API method for the Subnet resource or the SubnetService/List gRPC API call and provide the folder ID in the folderId request parameter.

    To learn how to find out the folder ID, see Getting the folder ID.

  • New subnet settings if needed:

    • Name in the name parameter.
    • Description in the description parameter.
    • Network labels in the labels parameter.
    • Route table ID in the routeTableId parameter.
    • DHCP settings in the dhcpOptions parameter.
  • List of settings to update in the updateMask parameter.

Warning

The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.

ExamplesExamples

Changing a subnet using the name flagChanging a subnet using the name flag

CLI

You can change a subnet by using its name instead of its ID:

yc vpc subnet update test-subnet-1 \
  --new-name test-subnet-renamed \
  --labels new_label=test_label

Result:

id: e2l2prrbkbim********
folder_id: b1g6ci08ma55********
created_at: "2018-10-24T13:54:10Z"
name: test-subnet-renamed
description: My test subnet
labels:
  new_label: test_label
network_id: enplom7a98s1********
zone_id: ru-central1-a
v4_cidr_blocks:
- 192.168.0.0/24

You can provide the subnet ID and name not only as positional arguments but also using the --id and --name flags:

yc vpc network update \
  --id enpavfmgapum******** \
  --new-name test-network-renamed \
  --labels new_label=test_label
yc vpc network update \
  --name test-network-1 \
  --new-name test-network-renamed \
  --labels new_label=test_label

Was the article helpful?

Previous
Deleting a subnet
Next
Getting information about a subnet
© 2025 Direct Cursus Technology L.L.C.