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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
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
  • Configure WordPress
  • 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 May 7, 2025
  • Get your cloud ready
    • Required paid resources
  • Create an infrastructure
  • Configure WordPress
  • 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. Configure WordPress.

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

Get your cloud readyGet your cloud ready

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.

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 documentation on the Terraform website or mirror website.

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 a provider, step 1).

  2. Prepare the infrastructure description files.

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

    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"]
      }
      

    For more information about the properties of Terraform resources, see the relevant Terraform 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 vary depending on an image. For more information, see Keys processed in public images Yandex Cloud.

  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.

Configure WordPressConfigure WordPress

To configure WordPress:

Management console

After the wordpress VM's status changes to RUNNING, do the following:

  1. Under Network on the VM page in the management console, find the VM's public IP address and enter it in the A resource record you previously created.

    add-ssh

  2. Open the domain name you configured or the VM's address in the browser.

  3. Select the language and click Continue.

    choose-language

  4. Fill out information to access the website:

    1. Enter any name for the website (for example, yc-wordpress).
    2. Specify the username to be used to log in to the admin panel (for example, yc-user).
    3. Enter the password to be used to log in to the admin panel.
    4. Enter your email address.

    credentials

  5. Click Install WordPress.

  6. If the installation is successful, click Log in.

    login

  7. Log in to the website with the username and password specified in the previous steps. This will open the admin panel where you can start working with your website.

  8. Make sure the website is accessible by opening the VM's public IP address in your browser.

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 configuration file and delete your 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 WordPress website using the management console.

Was the article helpful?

Previous
Management console
Next
Overview
Yandex project
© 2025 Yandex.Cloud LLC