Last active
January 5, 2021 19:33
-
-
Save parshyn-dima/9c26a2fe99140c6e88f2dad708500abe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "private_key_path" {} | |
provider "yandex" { | |
service_account_key_file = var.service_account_key_file | |
cloud_id = var.cloud_id | |
folder_id = var.folder_id | |
zone = var.zone | |
} | |
resource "yandex_compute_instance" "app" { | |
name = "reddit-app" | |
metadata = { | |
ssh-keys = "ubuntu:${file(var.public_key_path)}" | |
} | |
resources { | |
cores = 2 | |
memory = 2 | |
} | |
boot_disk { | |
initialize_params { | |
# Указать id образа созданного в предыдущем домашем задании | |
image_id = var.image_id | |
} | |
} | |
network_interface { | |
# Указан id подсети default-ru-central1-a | |
subnet_id = var.subnet_id | |
nat = true | |
} | |
connection { | |
type = "ssh" | |
host = yandex_compute_instance.app.network_interface.0.nat_ip_address | |
user = "ubuntu" | |
agent = false | |
# путь до приватного ключа | |
private_key = file(var.private_key_path) | |
} | |
provisioner "file" { | |
source = "files/puma.service" | |
destination = "/tmp/puma.service" | |
} | |
provisioner "remote-exec" { | |
script = "files/deploy.sh" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment