aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/yandex/server/main.tf
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-08-04 14:31:08 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-08-04 14:31:08 +0200
commit0e87875de0f5bbbade1ad3515c72abaadbe46204 (patch)
tree26d141bd7968f7f34091cf245ae1f11d6d3b2ee8 /yandex/server/main.tf
parentimport some common modules (diff)
downloadinfra-terraform-0e87875de0f5bbbade1ad3515c72abaadbe46204.tar.gz
infra-terraform-0e87875de0f5bbbade1ad3515c72abaadbe46204.zip
import a couple of Yandex Cloud moduelsv0.0.2
Diffstat (limited to '')
-rw-r--r--yandex/server/main.tf41
1 files changed, 41 insertions, 0 deletions
diff --git a/yandex/server/main.tf b/yandex/server/main.tf
new file mode 100644
index 0000000..12d31d9
--- /dev/null
+++ b/yandex/server/main.tf
@@ -0,0 +1,41 @@
+locals {
+ sshd_config = templatefile("${path.module}/etc/sshd_config", {
+ port = var.ssh_port
+ users = [var.user]
+ })
+}
+
+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 = templatefile("${path.module}/etc/cloud-init.cfg", {
+ user = var.user
+ ssh_keys = var.ssh_keys
+ sshd_config = local.sshd_config
+ })
+ }
+
+ allow_stopping_for_update = true
+}