Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Compute Cloud
  • Yandex Container Solution
    • All tutorials
    • Configuring time synchronization using NTP
    • Autoscaling an instance group to process messages from a queue
    • Updating an instance group under load
    • Deploying Remote Desktop Gateway
    • Getting started with Packer
    • Transferring logs from a VM to Yandex Cloud Logging
    • Building a VM image with infrastructure tools using Packer
    • Migrating data to Yandex Cloud using Hystax Acura
    • Fault protection with Hystax Acura
    • VM backups using Hystax Acura
    • Deploying a fault-tolerant architecture with preemptible VMs
    • Configuring a fault-tolerant architecture in Yandex Cloud
    • Creating a budget trigger that invokes a function to stop a VM
    • Creating triggers that invoke a function to stop a VM and send a Telegram notification
    • Creating a Python web application with Flask
    • Creating an SAP program in Yandex Cloud
    • Deploying a Minecraft server in Yandex Cloud
    • Automating image builds using Jenkins and Packer
    • Creating test VMs via GitLab CI
    • High-performance computing on preemptible VMs
      • Overview
      • Management console
      • Terraform
    • Configuring an SFTP server based on CentOS 7
    • Deploying GlusterFS in high availability mode
    • Deploying GlusterFS in high performance mode
    • Backing up to Object Storage with Bacula
    • Building a CI/CD pipeline in GitLab using serverless products
    • Implementing a secure high-availability network infrastructure with a dedicated DMZ based on the Check Point NGFW
    • Cloud infrastructure segmentation with the Check Point next-generation firewall
    • Configuring a secure GRE tunnel over IPsec
    • Creating a bastion host
    • Implementing fault-tolerant scenarios for NAT VMs
    • Creating a tunnel between two subnets using OpenVPN Access Server
    • Creating an external table from a Object Storage bucket table using a configuration file
    • Setting up network connectivity between BareMetal and Virtual Private Cloud subnets
    • Working with snapshots in Managed Service for Kubernetes
    • Launching the DeepSeek-R1 language model in a GPU cluster
    • Running a vLLM library with the Gemma 3 language model on a VM with GPU
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Getting started
  • Required paid resources
  • Create an infrastructure
  • Configure Samba and NFS
  • Test your file server
  • How to delete the resources you created
  1. Tutorials
  2. Single-node file server
  3. Terraform

Creating a single-node file server using Terraform

Written by
Yandex Cloud
Updated at May 7, 2025
  • Getting started
    • Required paid resources
  • Create an infrastructure
  • Configure Samba and NFS
  • Test your file server
  • How to delete the resources you created

To create an infrastructure for a single-node file server using Terraform:

  1. Get your cloud ready.
  2. Create an infrastructure.
  3. Configure Samba and NFS.
  4. Test your file server.

If you no longer need the resources you created, delete them.

Getting startedGetting started

Sign up in Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or register a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_ACTIVE status. If you do not have a billing account, create one and link a cloud to it.

If you have an active billing account, you can navigate to the cloud page to create or select a folder for your infrastructure to operate in.

Learn more about clouds and folders.

Required paid resourcesRequired paid resources

The cost for hosting a single node file server includes:

  • Fee for a continuously running VM (see Yandex Compute Cloud pricing).
  • Fee for using a dynamic or static public IP address (see Yandex Virtual Private Cloud pricing).
  • Fee for the outbound traffic (see Yandex Virtual Private Cloud pricing).

Create an infrastructureCreate an infrastructure

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

To create an infrastructure using Terraform:

  1. Install Terraform, get the credentials, and specify the source for installing Yandex Cloud (see Configure a provider, step 1).

  2. Prepare the infrastructure description files:

    Ready-made archive
    Manually
    1. Create a directory for the files.
    2. Download the archive (1 KB).
    3. Unpack the archive to the directory. This will add the single-node-file-server.tf configuration file to this directory.
    1. Create a directory for the files.

    2. In the directory, create a configuration file named single-node-file-server.tf:

      single-node-file-server.tf
      terraform {
        required_providers {
          yandex = {
            source  = "yandex-cloud/yandex"
            version = ">= 0.47.0"
          }
        }
      }
      
      provider "yandex" {
        zone = "ru-central1-a"
      }
      
      resource "yandex_vpc_network" "network-1" {
        name = "network1"
      }
      
      resource "yandex_vpc_subnet" "subnet-1" {
        name           = "subnet1"
        zone           = "ru-central1-a"
        network_id     = yandex_vpc_network.network-1.id
        v4_cidr_blocks = ["192.168.1.0/24"]
      }
      
      resource "yandex_vpc_security_group" "fileserver-tutorial-sg" {
        name       = "fileserver-tutorial-sg"
        network_id = yandex_vpc_network.network-1.id
      
        egress {
          protocol       = "ANY"
          description    = "any"
          v4_cidr_blocks = ["0.0.0.0/0"]
        }
      
        ingress {
          protocol       = "TCP"
          description    = "ext-http"
          v4_cidr_blocks = ["0.0.0.0/0"]
          port           = 80
        }
      
        ingress {
          protocol       = "TCP"
          description    = "ext-ssh"
          v4_cidr_blocks = ["0.0.0.0/0"]
          port           = 22
        }
      
        ingress {
          protocol       = "TCP"
          description    = "ext-https"
          v4_cidr_blocks = ["0.0.0.0/0"]
          port           = 443
        }
      
        ingress {
          protocol       = "TCP"
          description    = "ext-msql"
          v4_cidr_blocks = ["0.0.0.0/0"]
          port           = 3306
        }
      
        ingress {
          protocol       = "TCP"
          description    = "nfs"
          v4_cidr_blocks = ["0.0.0.0/0"]
          port           = 2049
        }
      }
      
      resource "yandex_compute_image" "ubuntu-1804-lts" {
        source_family = "ubuntu-1804-lts"
      }
      
      resource "yandex_compute_disk" "boot-disk-ubuntu" {
        name     = "fileserver-tutorial-disk"
        type     = "network-ssd"
        zone     = "ru-central1-a"
        size     = "100"
        image_id = yandex_compute_image.ubuntu-1804-lts.id
      }
      
      resource "yandex_compute_instance" "fileserver-tutorial" {
        name        = "fileserver-tutorial"
        platform_id = "standard-v3"
        zone        = "ru-central1-a"
      
        resources {
          core_fraction = 100
          cores         = 8
          memory        = 56
        }
      
        boot_disk {
          disk_id = yandex_compute_disk.boot-disk-ubuntu.id
        }
      
        network_interface {
          subnet_id          = yandex_vpc_subnet.subnet-1.id
          security_group_ids = [yandex_vpc_security_group.fileserver-tutorial-sg.id]
          nat                = true
        }
      
        metadata = {
          user-data = "#cloud-config\nusers:\n  - name: <username>\n    groups: sudo\n    shell: /bin/bash\n    sudo: 'ALL=(ALL) NOPASSWD:ALL'\n    ssh_authorized_keys:\n      - ${file("<path_to_public_SSH_key>")}"
        }
      }
      

    For more information about the properties of the Terraform resources, see the Terraform official website:

    • Network: yandex_vpc_network
    • Subnets: yandex_vpc_subnet
    • Security groups: yandex_vpc_security_group
    • VM image: yandex_compute_image
    • Disk: yandex_compute_disk
    • VM: yandex_compute_instance
  3. Under metadata, enter your username and the SSH key contents. For more information, see VM metadata.

  4. Create the resources:

    1. In the terminal, change to the folder where you edited the configuration file.

    2. Make sure the configuration file is correct using the command:

      terraform validate
      

      If the configuration is correct, the following message is returned:

      Success! The configuration is valid.
      
    3. Run the command:

      terraform plan
      

      The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.

    4. Apply the configuration changes:

      terraform apply
      
    5. Confirm the changes: type yes in the terminal and press Enter.

After creating the infrastructure, configure Samba and NFS.

Configure Samba and NFSConfigure Samba and NFS

After the fileserver-tutorial VM enters the RUNNING status, run:

  1. On the VM page of the management console, under Network, find the VM's public IP address.

  2. Connect to the VM over SSH.

    We recommend using a key pair when authenticating over SSH. Make sure to set up the created key pair so that the private key matches the public key sent to the VM.

  3. Configure Samba and NFS:

    Ubuntu
    1. Download and install Samba:

      sudo apt-get update
      sudo apt-get install nfs-kernel-server samba
      
    2. Prepare and mount the file system on the disk:

      sudo mkfs -t ext4 -L data /dev/vdb
      
    3. Prepare and mount a folder named my_folder for data storage on the disk:

      sudo mkdir /my_folder
      echo "LABEL=data /my_folder ext4 defaults 0 0" | sudo tee -a /etc/fstab
      sudo mount /my_folder
      
    4. Set the NFS configuration in the /etc/exports file. You can edit the file using nano:

      sudo nano /etc/exports
      

      Add the following lines to the file:

      /my_folder <IP_address>(rw,no_subtree_check,fsid=100)
      /my_folder 127.0.0.1(rw,no_subtree_check,fsid=100)
      

      Where <IP_address> is the IP address of the computer you are going to connect the network data disk to via NFS.

    5. Set the Samba configuration in the /etc/samba/smb.conf file. You can edit the file using nano:

      sudo nano /etc/samba/smb.conf
      

      Edit the file as follows:

      [global]
         workgroup = WORKGROUP
         server string = %h server (Samba)
         dns proxy = no
         log file = /var/log/samba/log.%m
         max log size = 1000
         syslog = 0
         panic action = /usr/share/samba/panic-action %d
         server role = standalone server
         passdb backend = tdbsam
         obey pam restrictions = yes
         unix password sync = yes
         passwd program = /usr/bin/passwd %u
         passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
         pam password change = yes
         map to guest = bad user
         usershare allow guests = yes
      [printers]
         comment = All Printers
         browseable = no
         path = /var/spool/samba
         printable = yes
         guest ok = no
         read only = yes
         create mask = 0700
      [print$]
         comment = Printer Drivers
         path = /var/lib/samba/printers
         browseable = yes
         read only = yes
         guest ok = no
      [data]
         comment = /my_folder
         path = /my_folder
         browseable = yes
         read only = no
         writable = yes
         guest ok = yes
         hosts allow = <IP_address> 127.0.0.1
         hosts deny = 0.0.0.0/0
      

      Where <IP_address> in the [data] section is the IP address of the computer you are going to connect the network data disk to via NFS.

    6. Restart Samba and NFS:

      sudo service nfs-kernel-server restart
      sudo service smbd restart
      

Test your file serverTest your file server

  1. Install ACL on the fileserver-tutorial VM:

    Ubuntu
    sudo apt install acl
    
  2. Create a directory named remote and a file named test.txt on the fileserver-tutorial VM:

    Ubuntu
    sudo mkdir /my_folder/remote
    sudo setfacl -m u:<your_username>:rwx /my_folder/remote
    echo "Hello world!" > /my_folder/remote/test.txt
    
  3. Connect the network disk to your computer via NFS and check if the test file is available:

    Linux/macOS
    Windows

    If needed, install the network disk utility:

    sudo apt-get install nfs-common
    

    Create a mount point:

    sudo mkdir /remote-test-dir
    

    Attach a network disk:

    sudo mount -t nfs <VM_public_IP_address>:/my_folder /remote-test-dir
    

    As as result, the test directory and the file should become available at the mount point.

    Note

    You may need to configure Windows security policies for access to the file server.

    1. Run the cmd.exe utility. To do this, use the Windows + R keyboard shortcut and run the cmd command.

    2. From the command line, run:

      net use x: \\<VM_public_IP_address>\data
      

    This will create a disk X with the test directory and file.

How to delete the resources you createdHow to delete the resources you created

To stop paying for the resources you created:

  1. Open the single-node-file-server.tf configuration file and delete the new infrastructure description from it.

  2. Apply the changes:

    1. In the terminal, change to the folder where you edited the configuration file.

    2. Make sure the configuration file is correct using the command:

      terraform validate
      

      If the configuration is correct, the following message is returned:

      Success! The configuration is valid.
      
    3. Run the command:

      terraform plan
      

      The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.

    4. Apply the configuration changes:

      terraform apply
      
    5. Confirm the changes: type yes in the terminal and press Enter.

See alsoSee also

  • Creating a single-node file server using the management console.

Was the article helpful?

Previous
Management console
Next
Configuring an SFTP server based on CentOS 7
© 2025 Direct Cursus Technology L.L.C.