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
    • All guides
      • Creating a placement group
      • Deleting a placement group
      • Creating a VM in a placement group
      • Creating an instance group in a placement group
      • Adding a VM to a placement group
      • Removing a VM from a placement group
      • Getting information about a placement group
      • Removing an instance group from a placement group
      • Configuring VM placement group access permissions
    • Viewing operations with resources
  • Yandex Container Solution
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  1. Step-by-step guides
  2. Placement groups
  3. Creating a VM in a placement group

Creating a VM in a placement group

Written by
Yandex Cloud
Updated at May 5, 2025

Create a VM in a placement group.

You can manage placement groups with partition placement using the CLI and API.

CLI
Terraform
API

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. See the description of the CLI command for creating a placement group:

    yc compute placement-group create --help
    
  2. Create a placement group in the default folder with one of the following placement strategies:

    • Spread placement:

      yc compute placement-group create \
        --spread-strategy \
        --name <placement_group_name>
      

      Where:

      • --spread-strategy: Shows that spread placement is selected.
      • --name: Placement group name.
    • Partition placement:

      yc compute placement-group create \
        --partitions <number_of_partitions> \
        --name <placement_group_name>
      

      Where:

      • --partitions: Shows that partition placement is selected, indicating the number of partitions from 1 to 5.
      • --name: Placement group name.
  3. See the description of the CLI command for creating a VM:

    yc compute instance create --help
    
  4. Create a VM:

    yc compute instance create \
      --zone ru-central1-a \
      --name instance-in-group-1 \
      --placement-group-name my-group \
      --placement-group-partition <partition_number>
    

    Where:

    • --zone: Availability zone for the VM.

    • --name: VM name.

    • --placement-group-name: Placement group name.

    • --placement-group-partition: Partition number in the placement group with the partition placement strategy.

      Note

      If you do not specify the partition number when creating a VM in a partition placement group, the VM will be added to a random partition.

    Result:

    id: epdep2kq6dt5********
    ...
    placement_policy:
      placement_group_id: fd83bv4rnsna********
    
  5. Check the new VM and its placement group:

    yc compute placement-group list-instances --name my-group
    

    Where --name is the placement group name.

    Result:

    +----------------------+---------------------+-------------------+---------+-------------+-------------+
    |          ID          |        NAME         |      ZONE ID      | STATUS  | EXTERNAL IP | INTERNAL IP |
    +----------------------+---------------------+-------------------+---------+-------------+-------------+
    | epdep2kq6dt5******** | instance-in-group-1 | ru-central1-a | RUNNING |             | 10.129.0.5  |
    +----------------------+---------------------+-------------------+---------+-------------+-------------+
    

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.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

To create a VM in a placement group:

  1. In the configuration file, define the VM parameters indicating the yandex_compute_placement_group resource in the placement_group_id field. The yandex_compute_instance resource describes the VM parameters.

    Here is an example of the configuration file structure:

    ...
    resource "yandex_compute_instance" "vm-1" {
      name        = "linux-vm"
      platform_id = "standard-v3"
      placement_policy {
        placement_group_id = "${yandex_compute_placement_group.group1.id}"
      }
    }
    
    resource "yandex_compute_placement_group" "group1" {
      name = "test-pg"
    }
    ...
    

    Where placement_group_id is the placement group ID.

    For more information about the yandex_compute_instance and yandex_compute_placement_group resource parameters in Terraform, see the relevant provider documentation.

  2. In the command line, go to the directory with the Terraform configuration file.

  3. Check the configuration using this command:

    terraform validate
    

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

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

    terraform plan
    

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

  5. Apply the configuration changes:

    terraform apply
    
  6. Confirm the changes: type yes into the terminal and press Enter.

    All the resources you need will then be created in the specified folder. You can check that the VM has been created and added to the placement group using the management console.

Use the create REST API method for the Instance resource or the InstanceService/Create gRPC API call.

See alsoSee also

  • Adding a VM to a placement group

Was the article helpful?

Previous
Deleting a placement group
Next
Creating an instance group in a placement group
© 2025 Direct Cursus Technology L.L.C.