and generating their terraform config
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 = "..." # INSTANCE-NAME to = yandex_compute_instance.server } # yc compute disk list | grep INSTANCE-ID import { id = "..." # DISK-NAME to = yandex_compute_disk.boot-disk } # yc vpc address list | grep PUBLIC-IP import { id = "..." # PUBLIC-IP to = yandex_vpc_address.static }
prepare your env
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` echo $YC_TOKEN echo $YC_CLOUD_ID
now ready to generate the definitions
terraform init terraform plan -generate-config-out=generated_resources.tf cat generated_resources.tf >> main.tf rm -f generated_resources.tf rm -rf .terraform* terraform init terraform plan terraform apply
FW https://developer.hashicorp.com/terraform/language/import/generating-configuration