Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
        • Overview
        • Management console
        • Terraform
      • Transferring a WordPress website from a different hosting provider to Yandex Cloud
      • Setting up virtual hosting
      • Creating a Python web application with Flask
      • Hosting a static Gatsby website
      • Migrating to Cloud CDN from a third-party CDN provider
      • Getting website traffic statistics with S3 Select

In this article:

  • Get your cloud ready
  • Required paid resources
  • Create an infrastructure
  • Get credentials for authenticating in the web interface
  • Connect to the WordPress web interface
  • How to delete the resources you created
  1. Application solutions
  2. Creating a website
  3. Creating a WordPress website
  4. Terraform

Creating a WordPress website using Terraform

Written by
Yandex Cloud
Updated at November 27, 2025
  • Get your cloud ready
    • Required paid resources
  • Create an infrastructure
  • Get credentials for authenticating in the web interface
  • Connect to the WordPress web interface
  • How to delete the resources you created

To create and set up a WordPress website using Terraform:

  1. Get your cloud ready.
  2. Create your infrastructure.
  3. Get credentials for authenticating in the web interface.
  4. Connect to the WordPress web interface.

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

Get your cloud readyGet your cloud ready

Sign up for Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or create 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.

Learn more about clouds and folders here.

Make sure the selected folder has a cloud network with a subnet in at least one availability zone. To do this, select VPC on the folder page. If the list contains a network, click its name to see the list of subnets. If the subnets or network you need are not listed, create them.

Required paid resourcesRequired paid resources

The cost of maintaining a WordPress website 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 public DNS queries and DNS zones if using Yandex Cloud DNS (see Cloud DNS 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 relevant documentation on the Terraform website or its mirror.

To create an infrastructure using Terraform:

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

  2. Prepare the infrastructure description files.

    Ready-made archive
    Manually
    1. Create a directory.
    2. Download the archive (1 KB).
    3. Unpack the archive to the directory. As a result, the wordpress.tf configuration file should appear in it.
    1. Create a directory.

    2. Create a configuration file named wordpress.tf in the folder:

      wordpress.tf
      terraform {
        required_providers {
          yandex = {
            source  = "yandex-cloud/yandex"
            version = ">= 0.47.0"
          }
        }
      }
      
      provider "yandex" {
        zone = "ru-central1-a"
      }
      
      resource "yandex_compute_image" "wordpress" {
        source_family = "wordpress"
      }
      
      resource "yandex_compute_disk" "boot-disk" {
        name     = "bootvmdisk"
        type     = "network-hdd"
        zone     = "ru-central1-a"
        size     = "20"
        image_id = yandex_compute_image.wordpress.id
      }
      
      resource "yandex_compute_instance" "vm-wordpress" {
        name        = "wordpress"
        platform_id = "standard-v3"
      
        resources {
          core_fraction = 20
          cores         = 2
          memory        = 1
        }
      
        boot_disk {
          disk_id = yandex_compute_disk.boot-disk.id
        }
      
        network_interface {
          subnet_id          = yandex_vpc_subnet.subnet-1.id
          nat                = true
          security_group_ids = ["${yandex_vpc_security_group.sg-1.id}"]
        }
      
        metadata = {
          ssh-keys = "<username>:<SSH_key_contents>"
        }
      }
      
      resource "yandex_vpc_security_group" "sg-1" {
        name        = "wordpress"
        description = "Description for security group"
        network_id  = yandex_vpc_network.network-1.id
      
        ingress {
          protocol       = "TCP"
          description    = "ext-http"
          v4_cidr_blocks = ["0.0.0.0/0"]
          port           = 80
        }
      
        ingress {
          protocol       = "TCP"
          description    = "ext-https"
          v4_cidr_blocks = ["0.0.0.0/0"]
          port           = 443
        }
      
        egress {
          protocol       = "ANY"
          description    = "any"
          v4_cidr_blocks = ["0.0.0.0/0"]
        }
      }
      
      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_dns_zone" "zone-1" {
        name        = "example-zone-1"
        description = "Public zone"
        zone        = "example.com."
        public      = true
      }
      
      resource "yandex_dns_recordset" "rs-1" {
        zone_id = yandex_dns_zone.zone-1.id
        name    = "example.com."
        ttl     = 600
        type    = "A"
        data    = ["${yandex_compute_instance.vm-wordpress.network_interface.0.nat_ip_address}"]
      }
      
      resource "yandex_dns_recordset" "rs-2" {
        zone_id = yandex_dns_zone.zone-1.id
        name    = "www"
        ttl     = 600
        type    = "CNAME"
        data    = ["example.com"]
      }
      

    Learn more about the properties of Terraform resources in the relevant provider guides:

    • VM instance: yandex_compute_instance
    • Security groups: yandex_vpc_security_group
    • Network: yandex_vpc_network
    • Subnets: yandex_vpc_subnet
    • DNS zone: yandex_dns_zone
    • DNS resource record: yandex_dns_recordset
  3. Under metadata, specify the metadata for creating a VM: <username>:<SSH_key_contents>. Regardless of the username specified, the key is assigned to the user set in the WordPress image configuration. Such users differ depending on the image. Learn more in Keys processed in public images Yandex Cloud.

  4. Create the resources:

    1. In the terminal, go to the directory where you edited the configuration file.

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

      terraform validate
      

      If the configuration is correct, you will get this message:

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

      terraform plan
      

      You will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.

    4. Apply the changes:

      terraform apply
      
    5. Type yes and press Enter to confirm the changes.

Get credentials for authenticating in the web interfaceGet credentials for authenticating in the web interface

When creating a VM, an administrator account for the web interface is created automatically. To get authentication credentials:

  1. Use SSH to connect to the VM you created:

    ssh <username>@<VM_public_IP_address>
    
  2. Switch to the root account:

    sudo su
    
  3. Open the file for reading:

    cat root/default_passwords.txt
    
  4. Copy the username and user password from the WP_ADMIN_USER and WP_ADMIN_PASSWORD lines.

Connect to the WordPress web interfaceConnect to the WordPress web interface

To connect to the WordPress web interface, do the following:

Management console
  1. In the management console, go to the VM page, find the VM public IP address under Network, and add it to the type A resource record you created earlier.

    add-ssh

  2. In your browser, open the WordPress admin panel using the domain name you configured or the VM's address: http://<domain_name_or_VM_public_address>/wp-admin.

  3. Enter the username and password you saved earlier.

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

To stop paying for the resources you created:

  1. Open the wordpress.tf file and delete your infrastructure description from it.

  2. Apply the changes:

    1. In the terminal, go to the directory where you edited the configuration file.

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

      terraform validate
      

      If the configuration is correct, you will get this message:

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

      terraform plan
      

      You will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.

    4. Apply the changes:

      terraform apply
      
    5. Type yes and press Enter to confirm the changes.

See alsoSee also

  • Creating a WordPress website using the management console.

Was the article helpful?

Previous
Management console
Next
Overview
© 2025 Direct Cursus Technology L.L.C.