Creating a cloud network
In addition to the cloud network in the default folder, you can create cloud networks in other folders.
To create a cloud network:
-
In the management console
, go to the folder where you need to create a cloud network. -
In the list of services, select Virtual Private Cloud.
-
In the top-right corner, click Create network.
-
In the Name field, enter a name for the network. The naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
(Optional) In the Description field, add a network description.
-
The default option is Create subnets. If you want to create the subnets later, disable this option.
-
Click Create network.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To create a cloud network:
-
See the description of the CLI command for creating a cloud network:
yc vpc network create --help
-
Create a cloud network in the default folder:
yc vpc network create \ --name test-network-1 \ --description "My test network"
The
--name
and--description
flags are optional: you can create a network without any name or description and access it by ID.The network naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
Get a list of all cloud networks in the default folder:
yc vpc network list
Result:
+----------------------+----------------+ | ID | NAME | +----------------------+----------------+ | enpiuvhhd4t8******** | test-network-1 | | enplom7a98s1******** | default | +----------------------+----------------+
Get the same list with more details in YAML format:
yc vpc network list --format yaml
Result:
- id: enpiuvhhd4t8******** folder_id: b1g6ci08ma55******** created_at: "2018-10-23T11:12:51Z" name: test-network-1 description: My first network - id: enplom7a98s1******** folder_id: b1g6ci08ma55******** created_at: "2018-09-24T08:23:00Z" name: default description: Auto-created default network
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the documentation on the Terraform
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the parameters of your cloud network:
-
name
: Name of the cloud network. The naming requirements are as follows:- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
description
: Description of the cloud network. -
labels
: Cloud network labels. Specify a key-value pair.
Here is an example of the configuration file structure:
resource "yandex_vpc_network" "default" { name = "<network_name>" description = "<network_description>" labels = { tf-label = "tf-label-value" empty-label = "" } }
For more information about the
vpc_network
resource parameters in Terraform, see the provider documentation . -
-
Make sure the configuration files are correct.
-
In the command line, go to the folder where you created the configuration file.
-
Run a check using this command:
terraform plan
If the configuration is described correctly, the terminal will display a list of created resources and their parameters. If the configuration contains any errors, Terraform will point them out.
-
-
Deploy cloud resources.
-
If the configuration does not contain any errors, run this command:
terraform apply
-
Confirm creating the resources: type
yes
in the terminal and press Enter.All the resources you need will then be created in the specified folder. You can check the new resources and their settings using the management console
or these CLI commands:yc vpc network list
-
To create a cloud network, use the create REST API method for the Network resource or the NetworkService/Create gRPC API call, and provide the following in the request:
- ID of the folder the network will reside in, in the
folderId
parameter. - Name of the new network in the
name
parameter. The name must be from 3 to 63 characters long, the last character cannot be a hyphen. - New network description in the
description
parameter. The description may be up to 256 characters long.
The name
and description
parameters are optional: you can create a network without any name or description and access it by ID.
To learn how to find out the folder ID, see Getting the folder ID.
Examples
Create a cloud network with a name and description in the selected folder:
yc vpc network create --name test-network-1 \
--description "My test network" \
--folder-id b1gnbfd11bq5********
-
In the configuration file, describe the parameters of the cloud network to create:
resource "yandex_vpc_network" "default" { name = "network-1" description = "My first network" }
For more information about resource parameters in Terraform, see the provider documentation
. -
Make sure the configuration files are correct.
-
In the command line, go to the folder where you created the configuration file.
-
Run a check using this command:
terraform plan
If the configuration is described correctly, the terminal will display a list of created resources and their parameters. If the configuration contains any errors, Terraform will point them out.
-
-
Deploy cloud resources.
-
If the configuration does not contain any errors, run this command:
terraform apply
-
Confirm creating the resources: type
yes
in the terminal and press Enter.All the resources you need will then be created in the specified folder. You can check the new resources and their settings using the management console
or these CLI commands:yc vpc network list
-