terraform-install | yandex-cli | terraform
mkdir -p ~/dev/cloud-terraform/
cd ~/dev/cloud-terraform/
vi providers.tf
terraform {
required_version = ">= 1.0.0"
required_providers {
yandex = {
source = "yandex-cloud/yandex"
}
}
}
–either– find your favorite image branch/family from the cli – BEWARE you need to increase output limit AFTER specifying folder-id
yc compute image list --format json --folder-id standard-images --limit 10000 | \
jq -r '.[] | select( .family == "debian-11-oslogin" )' | \
jq -r '.name + "," + .id + "," + .status' | sort -V | tail -5
yc compute image list --format json --folder-id standard-images --limit 10000 | \
jq -r '.[] | select( .family == "debian-12" )' | \
jq -r '.name + "," + .id + "," + .status ' | sort -V | tail -5
–or– just select one from the web console
Create instance Marketplace > search Debian
https://yandex.cloud/en/docs/compute/concepts/vm-platforms
https://yandex.cloud/en/docs/compute/concepts/performance-levels
we want
standard-v4a
here’s the minimal setup
2 vCPU 1 GB RAM garanteed 20%
and further minimum settings
SSD 5GB preemptible
that is
# as of jan 2026
image_id=fd8miiisblcuktpjr6sc
# <FOLDER>-ru-central1-d
zone_subnet_id=...
# openssh format
pubkey="..."
cat > main.tf <<EOF
resource "yandex_compute_disk" "boot" {
name = "testvm"
type = "network-ssd"
zone = "ru-central1-d"
size = "5"
image_id = "$image_id"
}
resource "yandex_compute_instance" "this" {
name = "testvm"
platform_id = "standard-v4a"
zone = "ru-central1-d"
resources {
cores = 2
memory = 1
core_fraction = 20
}
boot_disk {
disk_id = yandex_compute_disk.boot.id
}
# you need a public ip unless you have access to the internal subnet
network_interface {
subnet_id = "$zone_subnet_id"
nat = true
}
# username does not matter, as it depends on the image
metadata = {
ssh-keys = "debian:$pubkey"
serial-port-enable = 1
}
scheduling_policy {
preemptible = true
}
allow_stopping_for_update = true
}
EOF
note
# changing hostname re-defines everything - avoid that here even for the first shot #hostname = "test"
moar (unused)
# enable only once helper tools are installed
enable-oslogin = false
rm -rf .terraform* terraform init yc config profile list yc config profile activate test export YC_TOKEN=`yc iam create-token` export YC_CLOUD_ID=`yc config get cloud-id` export YC_FOLDER_ID=`yc config get folder-id` echo $YC_TOKEN echo $YC_CLOUD_ID echo $YC_FOLDER_ID terraform plan terraform apply
terraform import -no-color
https://yandex.cloud/en/docs/tutorials/infrastructure-management/terraform-quickstart#cli_1
https://yandex.cloud/en/docs/tutorials/infrastructure-management/terraform-modules
https://yandex.cloud/en/docs/tutorials/infrastructure-management/terraform-data-sources
https://terraform-provider.yandexcloud.net/Resources/compute_instance
https://terraform-provider.yandexcloud.net/Resources/organizationmanager_os_login_settings
https://github.com/yandex-cloud/terraform-provider-yandex
https://registry.terraform.io/providers/yandex-cloud/yandex/latest
https://spacelift.io/blog/importing-exisiting-infrastructure-into-terraform