aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/yandex/server/main.tf
blob: 97b326fc5e431e044f3697a8479af55b1cf3d50d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
locals {
  sshd_config = templatefile("${path.module}/../../etc/sshd_config", {
    port  = var.ssh_port
    users = [var.user]
  })
  user_data = templatefile("${path.module}/../../etc/cloud-init.cfg", {
    user        = var.user
    ssh_keys    = var.ssh_keys
    sshd_config = local.sshd_config
  })
}

resource "yandex_compute_instance" "this" {
  zone     = var.zone
  name     = var.name
  hostname = var.name

  resources {
    cores         = var.cores
    core_fraction = var.core_fraction
    memory        = var.memory
  }

  boot_disk {
    initialize_params {
      size     = var.disk_size
      image_id = var.image
    }
  }

  network_interface {
    subnet_id      = var.subnet_id
    nat            = true
    nat_ip_address = var.ip_address
  }

  metadata = {
    user-data = local.user_data
  }

  allow_stopping_for_update = true
}