> ## Documentation Index
> Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and manage a network

export const MethodSection = ({children}) => children ?? null;

export const MethodSwitch = ({children}) => {
  const tabs = React.Children.toArray(children).map(c => {
    if (!c || !c.props) return null;
    if (c.props.id) return c;
    const inner = c.props.children;
    if (inner && inner.props && inner.props.id) return inner;
    return null;
  }).filter(Boolean);
  const firstId = tabs.length > 0 ? tabs[0].props.id : "";
  const [active, setActive] = React.useState(firstId);
  React.useEffect(() => {
    try {
      const saved = localStorage.getItem("gcore_docs_method");
      if (saved && tabs.find(t => t.props.id === saved)) {
        setActive(saved);
      }
    } catch (_) {}
  }, []);
  React.useEffect(() => {
    try {
      document.querySelectorAll("h2[id], h3[id]").forEach(heading => {
        const visible = heading.offsetParent !== null;
        document.querySelectorAll(`a[href="#${heading.id}"]`).forEach(link => {
          if (link.closest("h1,h2,h3,h4,h5,h6")) return;
          const li = link.closest("li");
          if (li) li.style.display = visible ? "" : "none";
        });
      });
    } catch (_) {}
    window.dispatchEvent(new Event("scroll"));
  }, [active]);
  const handleClick = id => {
    setActive(id);
    try {
      localStorage.setItem("gcore_docs_method", id);
    } catch (_) {}
  };
  return <div>
      <div className="not-prose flex gap-0 border-b border-zinc-200 dark:border-zinc-800 mb-8 mt-2" role="tablist">
        {tabs.map(tab => {
    const isActive = active === tab.props.id;
    return <button key={tab.props.id} role="tab" aria-selected={isActive} onClick={() => handleClick(tab.props.id)} className={["px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer", isActive ? "border-primary text-primary" : "border-transparent text-zinc-500 hover:text-zinc-800 dark:hover:text-zinc-200"].join(" ")}>
              {tab.props.label}
            </button>;
  })}
      </div>

      {tabs.map(tab => <div key={tab.props.id} style={{
    display: active === tab.props.id ? "" : "none"
  }}>
          {tab.props.children}
        </div>)}
    </div>;
};

<MethodSwitch>
  <MethodSection id="portal" label="Customer Portal">
    <p>A Gcore Cloud network is a virtualized software-defined network that operates in a cloud computing infrastructure. Cloud networks are used to transfer information between cloud resources and provide an internet connection.</p>

    <p>Networks (also known as network interfaces) can be attached to [Virtual Machines](/cloud/virtual-instances/types-of-virtual-machines), [Bare Metal](/cloud/bare-metal-servers/about-bare-metal-servers), [Load Balancers](/cloud/networking/create-and-configure-a-load-balancer), and [Managed Kubernetes](/cloud/kubernetes/about-gcore-kubernetes) clusters.</p>

    ## Types of networks

    <p>The following network types are available for Cloud resources:</p>

    * **Private network** : This interface is for local internal connections to the server and doesn't have access to the external network. Resources with private interfaces can only be accessed from the same network, though internet connectivity can be established by adding a [Floating IP address](/cloud/networking/ip-address/create-and-configure-a-floating-ip-address) or placing the resource behind a public Load Balancer.
    * **Public network** : This interface grants access to the external network. Instances with a public network interface will be available from the internet.
    * **Dedicated network** : This network type is designed for individual usage, providing an exclusive pool of addresses for each client. It works with Bare Metal servers and supports assigning multiple public IP addresses to a single server, making it ideal for advanced use cases such as virtualization and traffic balancing. These networks rely on dedicated public subnets, and the number of supported public IPs depends on the size of the assigned subnet. Other customizations are available upon request to meet specific needs.

    <p>VMs use VxLAN networks; Bare Metal servers use VLAN networks.</p>

    ## Create and attach networks to cloud resources

    <p>Both public and private networks can be attached to VMs, Bare Metal, Load Balancers, and Managed Kubernetes clusters.</p>

    <p>There are two ways to create and attach a network: during resource creation or by adding a network separately and then attaching it to an existing Cloud resource.</p>

    <p>The support team must configure a dedicated network before it can be selected or used. This network type allows the assignment of multiple public IP addresses to a single server, with the total number of IPs determined by the size of the assigned subnet. Public IPs in a dedicated network must be explicitly assigned to the server in order to function. Unassigned IPs within the subnet will not be operational.</p>

    ### Attach a network when creating a new cloud resource

    <p>For each resource type, the network interface is configured separately:</p>

    * [Attach network interface to a Virtual Machine](/cloud/virtual-instances/create-an-instance)
    * [Attach network interface to a Bare Metal](/cloud/bare-metal-servers/create-a-bare-metal-server)
    * [Attach network interface to a Managed Kubernetes cluster](/cloud/kubernetes/clusters/create-a-kubernetes-cluster#step-6-configure-network-settings)
    * [Attach network interface to a Load Balancer](/cloud/networking/create-and-configure-a-load-balancer#step-4-configure-network)

    ### Create a network from the Networks page

    <p>New network interfaces can be created in the [Gcore Customer Portal](https://portal.gcore.com), on the **Networks** page.</p>

    <p>To add a new network:</p>

    1. In the Gcore Customer Portal, navigate to **Cloud** > **Networking**.
    2. Click **Create network**.

    <Frame>
      <img src="https://mintcdn.com/gcore/gc7JxAc22A27n3nY/images/docs/cloud/networking/create-and-manage-a-network/networking-page.png?fit=max&auto=format&n=gc7JxAc22A27n3nY&q=85&s=edd911287786d1b596b79119622fc5c7" alt="Create network page in the Customer Portal" width="1084" height="443" data-path="images/docs/cloud/networking/create-and-manage-a-network/networking-page.png" />
    </Frame>

    3. Enter the network name.
    4. (Optional) To create a network for Bare Metal servers, enable the **Bare Metal Network** toggle.
    5. (Optional) Enable **Add tags** to include metadata.
    6. Click **Create & Proceed**.

    <Frame>
      <img src="https://mintcdn.com/gcore/gc7JxAc22A27n3nY/images/docs/cloud/networking/create-and-manage-a-network/create-network-dialog.png?fit=max&auto=format&n=gc7JxAc22A27n3nY&q=85&s=9b6a44a2ae7fc8afac31b8cece5eb0cf" alt="Create network dialog" width="827" height="771" data-path="images/docs/cloud/networking/create-and-manage-a-network/create-network-dialog.png" />
    </Frame>

    <p>To configure a private network, add a [subnetwork](/cloud/networking/create-and-manage-a-subnetwork#create-a-subnetwork-from-the-networks-page) as well.</p>

    ### Attach a network interface to an existing VM or Bare Metal

    <Info>
      Network interfaces for created Load Balancers cannot be changed. If a different network configuration is needed, recreate the Load Balancer with the required settings.
    </Info>

    <p>To add more networks to an existing cloud resource, go to the resource settings:</p>

    1. In the Gcore Customer Portal, navigate to **Cloud**.
    2. Open the relevant page: **Virtual Instances** or **Bare Metal**.
    3. Click the resource name to open its settings.
    4. Go to the **Networking** tab to view, attach, and detach network interfaces. The following example shows the network configuration for a Virtual Machine:

    <Frame>
      <img src="https://mintcdn.com/gcore/gc7JxAc22A27n3nY/images/docs/cloud/networking/create-and-manage-a-network/networking-tab-vm.png?fit=max&auto=format&n=gc7JxAc22A27n3nY&q=85&s=b090e6425d897c57bf28df2874817a21" alt="Networking tab in the VM settings" width="1078" height="456" data-path="images/docs/cloud/networking/create-and-manage-a-network/networking-tab-vm.png" />
    </Frame>

    5. To attach a new interface, click **Add Interface**:

    * **Public**: Each virtual machine can only have one native public interface. To add more public IP addresses, use a [reserved IP address](/cloud/networking/ip-address/create-and-configure-a-reserved-ip-address) or [floating IP address](/cloud/networking/ip-address/create-and-configure-a-floating-ip-address) (applied to a private interface).

    <Info>
      Multiple public IP addresses can be assigned to a VM using floating IPs.
    </Info>

    * **Private**: Choose a network from the list or create a new one, then [configure a subnetwork](/cloud/networking/create-and-manage-a-subnetwork) as required.

    <Info>
      InfiniBand networks can only be attached to resources with flavors that support them.
    </Info>

    6. (Optional) If the network contains both IPv6 and IPv4 addresses, enable IPv6 dual-stack to use both protocols simultaneously on the same network infrastructure.
    7. Click **Save Changes**.

    <p>The network interface is now attached to the resource.</p>

    ## Detach a network from a VM or Bare Metal

    <p>To remove an interface from a cloud resource, detach all subnetworks within the network interface:</p>

    1. In the Gcore Customer Portal, navigate to **Cloud**.
    2. Open the relevant page with the resource: **Virtual Instances** or **Bare Metal**.
    3. Find the needed resource and click its name to open it.
    4. Go to the **Networking** tab and find the network to detach.
    5. Click the three-dot icon next to each subnetwork within the network and select **Detach Subnet**.

    <Frame>
      <img src="https://mintcdn.com/gcore/gc7JxAc22A27n3nY/images/docs/cloud/networking/create-and-manage-a-network/detach-subnetwork.png?fit=max&auto=format&n=gc7JxAc22A27n3nY&q=85&s=66d9077fe032c25f3f296ec908cdaac4" alt="Network settings with the detach subnetwork option" width="1094" height="392" data-path="images/docs/cloud/networking/create-and-manage-a-network/detach-subnetwork.png" />
    </Frame>

    <p>Detach any connected Floating IP before removing subnetworks.</p>

    6. Confirm the action by clicking **Detach**.

    <p>Repeat this step for all subnetworks within the network.</p>

    <Warning>
      Disabling a subnet automatically removes its network interface from the machine, causing network disconnection until a new interface is assigned.
    </Warning>

    ## Manage networks

    <p>All configured network interfaces and their subnetworks appear in the [Gcore Customer Portal](https://portal.gcore.com), on the **Networks** page.</p>

    <p>Network details, renaming, deletion, and subnetwork configuration are all available from this page.</p>

    ### View network details

    1. In the Gcore Customer Portal, navigate to **Cloud** > **Networking**.
    2. Find the needed network and click its name to open the details page.

    <p>The details page includes comprehensive information about the network, such as network ID, creation date, tags, and other relevant specifications.</p>

    <Frame>
      <img src="https://mintcdn.com/gcore/gc7JxAc22A27n3nY/images/docs/cloud/networking/create-and-manage-a-network/network-details.png?fit=max&auto=format&n=gc7JxAc22A27n3nY&q=85&s=6acc93a006b63f071588313c6835edfb" alt="Network details page" width="1103" height="554" data-path="images/docs/cloud/networking/create-and-manage-a-network/network-details.png" />
    </Frame>

    <p>[Subnetworks](/cloud/networking/create-and-manage-a-subnetwork) can also be created and removed from this page.</p>

    ### Port security

    <p>Port Security is enabled by default for all VMs, allowing only authorized traffic through network interfaces. To establish connectivity, a firewall must be configured. In some cases, such as specific network configurations or applications that require unrestricted access, turning off Port Security may be necessary.</p>

    <p>To disable Port Security:</p>

    1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to the Virtual Machine.
    2. Go to the **Networking** tab.
    3. Click on the three-dot menu next to the interface.
    4. Select **Disable Port Security**.

    <Frame>
      <img src="https://mintcdn.com/gcore/gc7JxAc22A27n3nY/images/docs/cloud/networking/create-and-manage-a-network/disable-port-security.png?fit=max&auto=format&n=gc7JxAc22A27n3nY&q=85&s=9e5f835882e47aff9d6e17f855e4eb72" alt="Disable port security" width="1092" height="474" data-path="images/docs/cloud/networking/create-and-manage-a-network/disable-port-security.png" />
    </Frame>

    <Info>
      Virtual Machines use only MAC addresses assigned by Gcore Cloud. Custom (virtual) MAC addresses are not supported.

      Custom MAC addresses are supported only on Bare Metal servers connected to private networks.
    </Info>

    ### Rename a network

    1. In the Gcore Customer Portal, navigate to **Cloud** > **Networking**.
    2. Find the network to rename and click the three-dot icon next to it.
    3. Select **Rename**.

    <Frame>
      <img src="https://mintcdn.com/gcore/gc7JxAc22A27n3nY/images/docs/cloud/networking/create-and-manage-a-network/rename-network.png?fit=max&auto=format&n=gc7JxAc22A27n3nY&q=85&s=23b967efb582c89b1f665d33349833ea" alt="Network settings menu with the rename button highlighted" width="1081" height="426" data-path="images/docs/cloud/networking/create-and-manage-a-network/rename-network.png" />
    </Frame>

    4. Enter a new name and click **Save** to apply the changes.

    <p>The network name is updated.</p>

    ### Delete a network

    1. In the Gcore Customer Portal, navigate to **Cloud** > **Networking**.
    2. Find the network to remove and click the three-dot icon next to it.
    3. Select **Delete**.

    <Frame>
      <img src="https://mintcdn.com/gcore/gc7JxAc22A27n3nY/images/docs/cloud/networking/create-and-manage-a-network/delete-network.png?fit=max&auto=format&n=gc7JxAc22A27n3nY&q=85&s=09601e181981a3ce2a2310c37d6d28c1" alt="Network settings menu with the delete button highlighted.png" width="1102" height="440" data-path="images/docs/cloud/networking/create-and-manage-a-network/delete-network.png" />
    </Frame>

    4. Click **Delete network** to confirm.

    <p>The network has been removed.</p>
  </MethodSection>

  <MethodSection id="api" label="REST API">
    <p>Creating a usable private network takes two API calls: create the network, then add a subnet to define the IP address range. Both calls are asynchronous and return a task ID to poll for completion. Full examples are provided in the sections below.</p>

    <Info>
      An [API token](/account-settings/api-tokens) is required, along with a [project ID](/api-reference/cloud/projects/list-projects) and [region ID](/api-reference/cloud/regions/list-regions).
    </Info>

    <p>Open a bash terminal and set these as environment variables before running the examples:</p>

    ```bash theme={null}
    export GCORE_API_KEY="{YOUR_API_KEY}"
    export GCORE_CLOUD_PROJECT_ID="{YOUR_PROJECT_ID}"
    export GCORE_CLOUD_REGION_ID="{YOUR_REGION_ID}"
    ```

    ## Quickstart

    <p>The scripts below create a private network and a subnet within it.</p>

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        import os
        from gcore import Gcore

        client = Gcore()

        # Step 1. Create a private network.
        network = client.cloud.networks.create_and_poll(name="my-network")
        network_id = network.id
        print(f"Network ID: {network_id}")

        # Step 2. Create a subnet with DHCP enabled.
        subnet = client.cloud.networks.subnets.create_and_poll(
            name="my-subnet",
            cidr="192.168.10.0/24",
            network_id=network_id,
            enable_dhcp=True,
        )
        print(f"Subnet ID: {subnet.id}, CIDR: {subnet.cidr}")
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        package main

        import (
            "context"
            "fmt"

            gcore "github.com/G-Core/gcore-go"
            "github.com/G-Core/gcore-go/cloud"
        )

        func main() {
            client := gcore.NewClient()
            ctx := context.Background()

            // Step 1. Create a private network.
            network, err := client.Cloud.Networks.NewAndPoll(ctx, cloud.NetworkNewParams{
                Name: "my-network",
            })
            if err != nil {
                panic(err.Error())
            }
            fmt.Printf("Network ID: %s\n", network.ID)

            // Step 2. Create a subnet with DHCP enabled.
            subnet, err := client.Cloud.Networks.Subnets.NewAndPoll(ctx, cloud.NetworkSubnetNewParams{
                NetworkID:  network.ID,
                Name:       "my-subnet",
                Cidr:       "192.168.10.0/24",
                EnableDhcp: gcore.Bool(true),
                IPVersion:  4,
            })
            if err != nil {
                panic(err.Error())
            }
            fmt.Printf("Subnet ID: %s, CIDR: %s\n", subnet.ID, subnet.Cidr)
        }
        ```
      </Tab>
    </Tabs>

    ## Step-by-step

    <p>Each step below explains what the call does, which parameters matter, and what the response looks like. Use this section to understand the flow or to debug a specific step.</p>

    <Accordion title="Show all steps">
      ### Step 1. Create a network

      A [network](/api-reference/cloud/networks/create-network) is the top-level container. Creating it also provisions a router that can later connect the subnet to external networks.

      | Parameter       | Required | Description                                                 |
      | --------------- | -------- | ----------------------------------------------------------- |
      | `name`          | Yes      | Display name for the network                                |
      | `type`          | No       | `vxlan` (default, for VMs) or `vlan` (for Bare Metal)       |
      | `create_router` | No       | Automatically create an external router; defaults to `true` |

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          network = client.cloud.networks.create_and_poll(name="my-network")
          network_id = network.id
          print(f"Network ID: {network_id}")
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          network, err := client.Cloud.Networks.NewAndPoll(ctx, cloud.NetworkNewParams{
              Name: "my-network",
          })
          if err != nil {
              panic(err.Error())
          }
          fmt.Printf("Network ID: %s\n", network.ID)
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X POST "https://api.gcore.com/cloud/v1/networks/$GCORE_CLOUD_PROJECT_ID/$GCORE_CLOUD_REGION_ID" \
            -H "Authorization: APIKey $GCORE_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{"name": "my-network"}'
          ```

          Response:

          ```json theme={null}
          {
            "tasks": ["fe5ad7f4-8b88-4d91-9d2f-c7be0b0c9e03"]
          }
          ```

          Poll <code>GET /cloud/v1/tasks/{task_id}</code> every 5 seconds until `state` is `FINISHED`. Save the network ID from `created_resources.networks[0]`:

          ```json theme={null}
          {
            "state": "FINISHED",
            "created_resources": {
              "networks": ["b4b8107a-7e90-4b9c-ae19-63de2cbc8a6f"],
              "routers": ["d2c3a1e0-5f1b-4c8d-9e2a-7b4f0c3d1e5f"]
            }
          }
          ```
        </Tab>
      </Tabs>

      ### Step 2. Create a subnet

      A [subnet](/api-reference/cloud/networks/create-subnet) defines the IP range and DHCP settings for the network. VMs attached to this network receive addresses from this range.

      | Parameter     | Required | Description                                         |
      | ------------- | -------- | --------------------------------------------------- |
      | `network_id`  | Yes      | ID of the network created in Step 1                 |
      | `cidr`        | Yes      | IP range in CIDR notation, e.g. `192.168.10.0/24`   |
      | `name`        | Yes      | Display name for the subnet                         |
      | `enable_dhcp` | No       | Automatically assign IPs to VMs; defaults to `true` |

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          subnet = client.cloud.networks.subnets.create_and_poll(
              name="my-subnet",
              cidr="192.168.10.0/24",
              network_id=network_id,
              enable_dhcp=True,
          )
          print(f"Subnet ID: {subnet.id}, CIDR: {subnet.cidr}")
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          subnet, err := client.Cloud.Networks.Subnets.NewAndPoll(ctx, cloud.NetworkSubnetNewParams{
              NetworkID:  network.ID,
              Name:       "my-subnet",
              Cidr:       "192.168.10.0/24",
              EnableDhcp: gcore.Bool(true),
              IPVersion:  4,
          })
          if err != nil {
              panic(err.Error())
          }
          fmt.Printf("Subnet ID: %s, CIDR: %s\n", subnet.ID, subnet.Cidr)
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X POST "https://api.gcore.com/cloud/v1/subnets/$GCORE_CLOUD_PROJECT_ID/$GCORE_CLOUD_REGION_ID" \
            -H "Authorization: APIKey $GCORE_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "name": "my-subnet",
              "network_id": "'"$NETWORK_ID"'",
              "cidr": "192.168.10.0/24",
              "enable_dhcp": true
            }'
          ```

          Response:

          ```json theme={null}
          {
            "tasks": ["4bc1a043-008e-410f-8a10-3ededf9a9a7b"]
          }
          ```

          Poll <code>GET /cloud/v1/tasks/{task_id}</code> until `state` is `FINISHED`. Save the subnet ID from `created_resources.subnets[0]`:

          ```json theme={null}
          {
            "state": "FINISHED",
            "created_resources": {
              "subnets": ["cf3ca33f-ad0d-457d-8bf2-919dc8c76155"]
            }
          }
          ```
        </Tab>
      </Tabs>
    </Accordion>

    ## Rename a network

    <p>Renaming is a synchronous operation — no task polling required.</p>

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        updated = client.cloud.networks.update(network_id, name="my-network-renamed")
        print(f"New name: {updated.name}")
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        // Add "github.com/G-Core/gcore-go/packages/param" to your imports.
        updated, err := client.Cloud.Networks.Update(ctx, networkID, cloud.NetworkUpdateParams{
            Name:      param.NewOpt("my-network-renamed"),
        })
        if err != nil {
            panic(err.Error())
        }
        fmt.Printf("New name: %s\n", updated.Name)
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl -X PATCH "https://api.gcore.com/cloud/v1/networks/$GCORE_CLOUD_PROJECT_ID/$GCORE_CLOUD_REGION_ID/$NETWORK_ID" \
          -H "Authorization: APIKey $GCORE_API_KEY" \
          -H "Content-Type: application/json" \
          -d '{"name": "my-network-renamed"}'
        ```

        Response:

        ```json theme={null}
        {
          "id": "b4b8107a-7e90-4b9c-ae19-63de2cbc8a6f",
          "name": "my-network-renamed",
          "type": "vxlan",
          "region_id": 148,
          "project_id": 1186668
        }
        ```
      </Tab>
    </Tabs>

    ## Clean up

    <p>Deleting the network removes all attached subnets automatically. Delete the network:</p>

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        client.cloud.networks.delete_and_poll(network_id=network_id)
        print("Network deleted.")
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        err = client.Cloud.Networks.DeleteAndPoll(ctx, networkID, cloud.NetworkDeleteParams{})
        if err != nil {
            panic(err.Error())
        }
        fmt.Println("Network deleted.")
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl -X DELETE "https://api.gcore.com/cloud/v1/networks/$GCORE_CLOUD_PROJECT_ID/$GCORE_CLOUD_REGION_ID/$NETWORK_ID" \
          -H "Authorization: APIKey $GCORE_API_KEY"
        ```

        Response:

        ```json theme={null}
        {
          "tasks": ["5c00c510-a9c9-4c55-ae05-2d413a0bf2f1"]
        }
        ```

        Poll <code>GET /cloud/v1/tasks/{task_id}</code> until `state` is `FINISHED` to confirm deletion.
      </Tab>
    </Tabs>
  </MethodSection>

  <MethodSection id="terraform" label="Terraform">
    <p>Declare a private network and its subnet as a pair — both are required before any resource can receive an IP address. The [Terraform provider](/developer-tools/terraform/overview) exposes [`gcore_cloud_network`](https://registry.terraform.io/providers/G-Core/gcore/latest/docs/resources/cloud_network) and `gcore_cloud_network_subnet` as separate resources.</p>

    ## Create a network and subnet

    <p>Defines a private network and a subnet within it. Use `type = "vxlan"` for Virtual Machines (default) or `type = "vlan"` for Bare Metal servers.</p>

    ```hcl theme={null}
    resource "gcore_cloud_network" "example" {
      project_id = var.project_id
      region_id  = var.region_id
      name       = "my-network"
      type       = "vxlan"
    }

    resource "gcore_cloud_network_subnet" "example" {
      project_id = var.project_id
      region_id  = var.region_id
      name       = "my-subnet"
      cidr       = "192.168.10.0/24"
      network_id = gcore_cloud_network.example.id
    }

    output "network_id" {
      value = gcore_cloud_network.example.id
    }
    ```

    ## Rename a network

    <p>Edit `name` in the network resource block and run `terraform apply`.</p>

    ```hcl theme={null}
    resource "gcore_cloud_network" "example" {
      project_id = var.project_id
      region_id  = var.region_id
      name       = "my-network-renamed"
      type       = "vxlan"
    }

    resource "gcore_cloud_network_subnet" "example" {
      project_id = var.project_id
      region_id  = var.region_id
      name       = "my-subnet"
      cidr       = "192.168.10.0/24"
      network_id = gcore_cloud_network.example.id
    }
    ```

    ## Delete a network and subnet

    <Warning>
      Deleting a network removes the subnet and disconnects any attached resources.
    </Warning>

    <p>Remove both resource blocks — Terraform deletes the subnet first, then the network, on the next `terraform apply`.</p>

    ```hcl theme={null}
    # Remove or comment out both blocks:
    # resource "gcore_cloud_network" "example" {
    #   project_id = var.project_id
    #   region_id  = var.region_id
    #   name       = "my-network"
    #   type       = "vxlan"
    # }
    # resource "gcore_cloud_network_subnet" "example" {
    #   project_id = var.project_id
    #   region_id  = var.region_id
    #   name       = "my-subnet"
    #   cidr       = "192.168.10.0/24"
    #   network_id = gcore_cloud_network.example.id
    # }
    ```

    ```bash theme={null}
    terraform apply
    ```

    ## Import a network and subnet

    <p>Use to bring a network and its subnet created outside Terraform under configuration management. Each resource is imported separately.</p>

    ```hcl theme={null}
    resource "gcore_cloud_network" "existing" {
      project_id = var.project_id
      region_id  = var.region_id
      name       = "my-network"
      type       = "vxlan"
    }

    resource "gcore_cloud_network_subnet" "existing" {
      project_id = var.project_id
      region_id  = var.region_id
      name       = "my-subnet"
      cidr       = "192.168.10.0/24"
      network_id = gcore_cloud_network.existing.id
    }

    # terraform import gcore_cloud_network.existing '<project_id>/<region_id>/<network_id>'
    # terraform import gcore_cloud_network_subnet.existing '<project_id>/<region_id>/<subnet_id>'
    ```
  </MethodSection>
</MethodSwitch>
