---
title: "Create a GPU-enabled fixed-configuration cloud server with a bootable network volume via Terraform"
sidebar_label: "Create a GPU-enabled fixed-configuration server with a bootable network volume"
sidebar_position: 5
description: "How to create a GPU-enabled fixed-configuration cloud server with a bootable network volume"
---

import Formbricks from '@theme/MDXComponents/Formbricks'
import ConfigureProviders from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/common/configure-providers.mdx'
import ConfigureProvidersConfig from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/common/configure-providers-config.mdx'
import CreateRouter from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-networks/create-router.mdx'
import CreateNetworks from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-networks/create-networks.mdx'
import AddPublicSsh from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-servers/add-public-ssh-key.mdx'
import CreatePort from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-servers/create-port.mdx'
import GetImage from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-servers/get-image.mdx'
import CreateResourcesAlert from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/common/create-resources-alert.mdx'
import CreateBootVolume from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-servers/create-boot-volume.mdx'
import CreatePublicIp from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-networks/create-public-ip.mdx'
import AssociateIp from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-networks/associate-ip.mdx'
import GetIp from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-networks/get-ip.mdx'

# Create a GPU-enabled fixed-configuration cloud server with a bootable network volume via Terraform

<CreateResourcesAlert />

<br />

1. Optional: [configure providers](#configure-providers).

2. [Add a public SSH key](#create-ssh-keypair).

3. [Create a private network and subnet](#create-networks).

4. [Create a cloud router connected to the internet](#create-router).

5. [Create a port for the cloud server](#create-port).

6. [Get an image](#get-image).

7. [Create a bootable network volume](#create-boot-volume).

8. [Create a cloud server](#create-server).

9. [Create a public IP address](#create-public-ip).

10. [Associate the cloud server's public and private IP addresses](#associate-ip).

11. [Get the cloud server's address](#get-ip).

## Configuration files \{#config}

<details>
  <summary>Example file for provider configuration</summary>

  <ConfigureProvidersConfig />
</details>

<details>
  <summary>Example file for creating a GPU-accelerated server</summary>

  ```hcl

  resource "selectel_vpc_keypair_v2" "keypair_1" {
      name       = "keypair"
      public_key = file("~/.ssh/id_rsa.pub")
      user_id    = selectel_iam_serviceuser_v1.serviceuser_1.id
  }

  resource "openstack_networking_network_v2" "network_1" {
      name           = "private-network"
      admin_state_up = "true"
  }

  resource "openstack_networking_subnet_v2" "subnet_1" {
      network_id = openstack_networking_network_v2.network_1.id
      cidr       = "192.168.199.0/24"
  }

  data "openstack_networking_network_v2" "external_network_1" {
      external = true
  }

  resource "openstack_networking_router_v2" "router_1" {
      name                = "router"
      external_network_id = data.openstack_networking_network_v2.external_network_1.id
  }

  resource "openstack_networking_router_interface_v2" "router_interface_1" {
      router_id = openstack_networking_router_v2.router_1.id
      subnet_id = openstack_networking_subnet_v2.subnet_1.id
  }

  resource "openstack_networking_port_v2" "port_1" {
      name       = "port"
      network_id = openstack_networking_network_v2.network_1.id

      fixed_ip {
        subnet_id = openstack_networking_subnet_v2.subnet_1.id
      }
  }

  data "openstack_images_image_v2" "image_1" {
      name        = "Ubuntu 20.04 LTS 64-bit"
      most_recent = true
      visibility  = "public"
  }

  resource "openstack_blockstorage_volume_v3" "volume_1" {
      name                 = "boot-volume-for-server"
      size                 = "5"
      image_id             = data.openstack_images_image_v2.image_1.id
      volume_type          = "fast.ru-9a"
      availability_zone    = "ru-9a"
      enable_online_resize = true

      lifecycle {
        ignore_changes = [image_id]
      }

  }

  resource "openstack_compute_instance_v2" "server_1" {
    name              = "server"
    flavor_id         = "3042"
    key_pair          = selectel_vpc_keypair_v2.keypair_1.name
    availability_zone = "ru-9a"

    network {
      port = openstack_networking_port_v2.port_1.id
    }

    lifecycle {
      ignore_changes = [image_id]
    }

    block_device {
      uuid             = openstack_blockstorage_volume_v3.volume_1.id
      source_type      = "volume"
      destination_type = "volume"
      boot_index       = 0
    }

    vendor_options {
      ignore_resize_confirmation = true
    }
  }

  resource "openstack_networking_floatingip_v2" "floatingip_1" {
      pool = "external-network"
  }

  resource "openstack_networking_floatingip_associate_v2" "association_1" {
      port_id     = openstack_networking_port_v2.port_1.id
      floating_ip = openstack_networking_floatingip_v2.floatingip_1.address
  }

  output "public_ip_address" {
      value = openstack_networking_floatingip_v2.floatingip_1.fixed_ip
  }

  ```
</details>

## 1. Optional: configure providers \{#configure-providers}

If you have already configured the Selectel and OpenStack providers, skip this step.

<ConfigureProviders />

## 2. Create an SSH key pair \{#create-ssh-keypair}

<AddPublicSsh />

## 3. Create a private network and subnet \{#create-networks}

<CreateNetworks />

## 4. Create a cloud router connected to the internet \{#create-router}

<CreateRouter />

## 5. Create a port for the cloud server \{#create-port}

<CreatePort />

## 6. Get an image \{#get-image}

<GetImage />

## 7. Create a bootable network volume \{#create-boot-volume}

<CreateBootVolume />

## 8. Create a cloud server \{#create-server}

```hcl

resource "openstack_compute_instance_v2" "server_1" {
  name              = "server"
  flavor_id         = "3042"
  key_pair          = selectel_vpc_keypair_v2.keypair_1.name
  availability_zone = "ru-9a"

  network {
    port = openstack_networking_port_v2.port_1.id
  }

  lifecycle {
    ignore_changes = [image_id]
  }

  block_device {
    uuid             = openstack_blockstorage_volume_v3.volume_1.id
    source_type      = "volume"
    destination_type = "volume"
    boot_index       = 0
  }

  vendor_options {
    ignore_resize_confirmation = true
  }
}

```

Where:

* `availability_zone` — [pool segment](/infrastructure/locations/#pool) where the cloud server will be created, for example `ru-9a`. The list of available pool segments can be found in the instructions [Product availability by location](/infrastructure/product-availability-by-location/).
* `flavor_id` — flavor ID. Flavors correspond to [cloud server configurations](/cloud-servers/create/configurations/) and determine the number of vCPUs, amount of RAM, and size of the local disk. For example, `3042` is a fixed configuration flavor from the GPU lineup with 2 GPUs, 12 vCPUs, and 175 GB of RAM. A list of available flavors can be found in the [List of fixed configuration flavors in all pools](/cloud-servers/create/configurations/#server-flavors-full-list) section of the Cloud Server Configurations instructions.

See the detailed description of the [openstack\_compute\_instance\_v2](/terraform/openstack-provider-reference/compute-nova/resources/openstack_compute_instance_v2/) resource.

## 9. Create a public IP address \{#create-public-ip}

<CreatePublicIp />

## 10. Associate the cloud server's public and private IP addresses \{#associate-ip}

<AssociateIp />

## 11. Get the cloud server IP address \{#get-ip}

<GetIp />

<Formbricks />
