---
title: "Create HDD Basic file storage via Terraform"
sidebar_label: "Create file storage"
description: "How to create HDD Basic file storage"
sidebar_position: 1
---

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 CreateNetworks from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/cloud-networks/create-networks.mdx'
import CreateResourcesAlert from '@site/i18n/en/docusaurus-plugin-content-docs-terraform/current/_partials/common/create-resources-alert.mdx'

# Create HDD Basic file storage via Terraform

<CreateResourcesAlert />

<br />

1. Optional: [configure providers](#configure-providers).
2. [Create a private network and subnet](#create-networks).
3. [Configure the storage network](#configure-storage-network).
4. [Create a file storage](#create-storage).
5. [Configure file storage access rules](#configure-access).

## Configuration files \{#config}

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

  <ConfigureProvidersConfig />
</details>

<details>
  <summary>Example file for creating file storage</summary>

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

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

  resource "openstack_sharedfilesystem_sharenetwork_v2" "sharenetwork_1" {
    name              = "share-network"
    neutron_net_id    = openstack_networking_network_v2.network_1.id
    neutron_subnet_id = openstack_networking_subnet_v2.subnet_1.id
  }

  resource "openstack_sharedfilesystem_share_v2" "share_1" {
    name             = "nfs-storage"
    share_type       = "basic.ru-9a"
    share_proto      = "NFS"
    size             = 50
    share_network_id = openstack_sharedfilesystem_sharenetwork_v2.sharenetwork_1.id
    metadata         = {"ip": "192.168.199.3"}
  }

  resource "openstack_sharedfilesystem_share_access_v2" "shareaccess_1" {
    access_level = "rw"
    access_to    = "0.0.0.0/0"
    access_type  = "ip"
    share_id     = openstack_sharedfilesystem_share_v2.share_1.id
  }
  ```
</details>

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

If you have [configured the Selectel and OpenStack providers](/terraform/configure-terraform-environment/#configure-providers), skip this step.

<ConfigureProviders />

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

<CreateNetworks />

## 3. Configure the storage network \{#configure-storage-network}

```hcl
resource "openstack_sharedfilesystem_sharenetwork_v2" "sharenetwork_1" {
  name              = "share-network"
  neutron_net_id    = openstack_networking_network_v2.network_1.id
  neutron_subnet_id = openstack_networking_subnet_v2.subnet_1.id
}
```

See the detailed resource description [openstack\_sharedfilesystem\_sharenetwork\_v2](/terraform/openstack-provider-reference/shared-filesystem-manila/resources/openstack_sharedfilesystem_sharenetwork_v2/).

## 4. Create a file storage \{#create-storage}

```hcl
resource "openstack_sharedfilesystem_share_v2" "share_1" {
  name             = "nfs-storage"
  share_type       = "basic.ru-9a"
  share_proto      = "NFS"
  size             = 50
  share_network_id = openstack_sharedfilesystem_sharenetwork_v2.sharenetwork_1.id
  metadata         = {"ip": "192.168.199.3"}
}
```

Where:

* `share_type` — [file storage type](/file-storage/about/about-file-storage/#file-storage-types) and [pool segment](/infrastructure/locations/#pool) in the format `<type>.<pool_segment>`, e.g. `basic.ru-9a`:
  * `<type>:`
    * `basic` — HDD Basic type;
    * `universal` — SSD Universal type;
    * `fast` — SSD Fast type;
  * `<pool_segment>` — pool segment where the file storage will be created, for example, `ru-9a`. For a list of available pool segments, see the instructions on [Product availability by location](/infrastructure/product-availability-by-location/);
* `share_proto` — file storage protocol: `NFS` or `CIFS`;
* `size` — file storage size in GB, e.g. `50`. Limitations — from 50 GB to 50 TB;
* optional: `metadata = {"ip": "<ip_address>"}` — private IP address of the file storage, e.g. `192.168.0.3`. After the storage is created, the IP address cannot be changed.

See the detailed resource description [openstack\_sharedfilesystem\_share\_v2](/terraform/openstack-provider-reference/shared-filesystem-manila/resources/openstack_sharedfilesystem_share_v2/).

## 5. Configure file storage access rules \{#configure-access}

```hcl
resource "openstack_sharedfilesystem_share_access_v2" "shareaccess_1" {
  access_level = "rw"
  access_to    = "0.0.0.0/0"
  access_type  = "ip"
  share_id     = openstack_sharedfilesystem_share_v2.share_1.id
}
```

Where:

* `access_level` — [access level](/file-storage/manage/configure-access-by-ips/#access-levels) to the storage, depends on the protocol:
  * for CIFS SMBv3 — `rw` (read and write);
  * for NFSv4 — `ro` (read-only) or `rw` (read and write);
* `access_to` — IP address or CIDR of the private subnet to which access will be granted. For example:
  * `192.168.199.10` — access for an IP address;
  * `192.168.199.0/24` — access for a private subnet range;
  * `0.0.0.0/0` — access for all private subnet addresses. To configure this access, you can add the [openstack\_sharedfilesystem\_share\_v2](#create-storage) resource line `metadata = {"access_list_allow_all": "true"}`.

See the detailed resource description [openstack\_sharedfilesystem\_share\_access\_v2](/terraform/openstack-provider-reference/shared-filesystem-manila/resources/openstack_sharedfilesystem_share_access_v2/).

<Formbricks />
