Created
January 5, 2021 19:48
-
-
Save parshyn-dima/77a71d6758d114c2b48311a7691c05be 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" | |
} | |
} | |
resource "yandex_compute_instance" "app2" { | |
name = "reddit-app2" | |
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.app2.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