diff --git a/slinvm/main.tf b/slinvm/main.tf new file mode 100644 index 0000000..47a44b1 --- /dev/null +++ b/slinvm/main.tf @@ -0,0 +1,60 @@ +terraform { + required_providers { + yandex = { + source = "yandex-cloud/yandex" + } + } +} + +provider "yandex" { + zone = "ru-central1-b" +} + +resource "yandex_compute_instance" "vm" { + count = 1 + + name = "vm${count.index}" + platform_id = "standard-v1" + boot_disk { + initialize_params { + image_id = "fd87j6d92jlrbjqbl32q" # ubuntu 22.04 + size = 8 + } + } + + network_interface { + subnet_id = yandex_vpc_subnet.subnet1.id + nat = true + } + + resources { + cores = 2 + memory = 2 + } + + metadata = { + ssh-keys = "ubuntu:${file("~/.ssh/id_ed25519.pub")}" + hostname = "slinvm" + } +} + +resource "yandex_vpc_network" "network1" { + name = "network1" +} + +resource "yandex_vpc_subnet" "subnet1" { + name = "subnet1" + v4_cidr_blocks = ["172.24.8.0/24"] + network_id = yandex_vpc_network.network1.id +} + +resource "local_file" "ssh_connect" { + file_permission = "0755" + filename = "${path.module}/ssh_connect" + content = <