and generating their terraform config
make sure you’re on the right profile
yc config profile list yc config profile activate test
start with a MWE and no definitions
vi providers.tf
terraform {
required_providers {
yandex = {
source = "yandex-cloud/yandex"
}
}
required_version = ">= 1.0.0"
}
vi main.tf
# yc compute instance list | grep INSTANCE-NAME
import {
id = "..."
to = yandex_compute_instance.server
}
# yc compute disk list | grep INSTANCE-ID
import {
id = "..."
to = yandex_compute_disk.boot-disk
}
# optional for public ip
# yc vpc address list | grep PUBLIC-IP OR INSTANCE-NAME
import {
id = "..."
to = yandex_vpc_address.static
}
also for security groups
# yc vpc security-group list | grep SG-NAME
import {
id = "..."
to = yandex_vpc_security_group.SG-NAME
}
also for dns zones
# yc dns zone list | grep ZONE
import {
id = "..."
to = yandex_dns_zone.zone
}
also for dns record sets
import {
id = "ZONE-ID/FQDN./RECORD-TYPE"
to = yandex_dns_recordset.rs
}
prepare your env
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
now ready to generate the definitions
HOME | GUIDES | PLAYBOOKS | LECTURES | LAB | CONTACT | HTML | CSSrm -rf .terraform* terraform init terraform plan -generate-config-out=import.tf terraform plan terraform apply