Create an internal network

You can picture DoubleCloud internal networks as similar to a traditional LAN in a data center: use them for transmitting information between resources and connecting them to the internet.

To create an internal network:

  1. Go to the VPC service page in console.

  2. Click Create Network.

  3. In the popup window:

    1. Select a region.

    2. Specify the network's CIDR. You can use the online CIDR calculator for convenience.

    3. Enter the network's name.

    4. Click Create.

Your network will appear on the list with the Creating status. When operational, it'll change to Active.

To create an internal network, use the NetworkService create method and pass the following parameters:

  • project_id - the id of the project for which you want to create a network.

  • cloud_type - aws or gcp.

  • region_id - for the list of available regions and their region codes, see Areas and regions for Managed Service for ClickHouse®.

  • name - you new connection's name. Must be unique within the project.

  • ipv4_cidr_block - IPv4 subnet network range in the CIDR notation.

    You can use the online CIDR calculator for convenience.

import json
import logging

import doublecloud

from doublecloud.network.v1.network_service_pb2 import CreateNetworkRequest
from doublecloud.network.v1.network_service_pb2_grpc import NetworkServiceStub

def create_network(sdk, project_id, region_id, name, ipv4_cidr_block):
    network_service = sdk.client(NetworkServiceStub)
    operation = network_service.Create(
        CreateNetworkRequest(
            project_id=<your_project_id>,
            cloud_type="aws",
            region_id=<network_region_id>,
            name=name,
           ipv4_cidr_block=<cidr_block_in_ipv4_format>,
        )
    )
    logging.info("Creating initiated")
    return operation

For more in-depth examples, check out DoubleCloud API Python SDK repository .

func createNetwork(ctx context.Context, dc *dc.SDK, flags *cmdFlags) (*operation.Operation, error) {
   x, err := dc.Network().Network().Create(ctx, &network.CreateNetworkRequest{
      ProjectId:     *flags.projectID,
      Name:          *flags.name,
      CloudType:     *flags.cloudType,
      RegionId:      *flags.region,
      Ipv4CidrBlock: *flags.ipv4CIDR,
   })
   if err != nil {
      return nil, err
   }
   log.Println("Creating network ...")
   op, err := dc.WrapOperation(x, err)
   if err != nil {
      panic(err)
   }
   err = op.Wait(ctx)
   return op, err
}

For more in-depth examples, check out DoubleCloud API Go SDK repository .

See also