-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5999e7e
commit 34fae9d
Showing
7 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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" | ||
labels = { | ||
tags = "reddit-app" | ||
} | ||
resources { | ||
core_fraction = 20 | ||
cores = 2 | ||
memory = 2 | ||
} | ||
boot_disk { | ||
initialize_params { | ||
image_id = var.app_disk_image | ||
} | ||
} | ||
network_interface { | ||
subnet_id = var.subnet_id | ||
nat = true | ||
} | ||
metadata = { | ||
ssh-keys = "ubuntu:${file(var.public_key_path)}" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "external_ip_address_app" { | ||
value = yandex_compute_instance.app.network_interface.0.nat_ip_address | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
variable "public_key_path" { | ||
# Описание переменной | ||
description = "Path to the public key used for ssh access" | ||
} | ||
variable "subnet_id" { | ||
description = "Subnet" | ||
} | ||
variable app_disk_image { | ||
description = "Disk image for reddit app" | ||
default = "reddit-app-base" | ||
} | ||
variable "zone" { | ||
description = "Zone" | ||
# Значение по умолчанию | ||
default = "ru-central1-a" | ||
} | ||
variable "cloud_id" { | ||
description = "Cloud" | ||
} | ||
variable "service_account_key_file" { | ||
description = "key.json" | ||
} | ||
variable "folder_id" { | ||
description = "Folder" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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" "db" { | ||
name = "reddit-db" | ||
labels = { | ||
tags = "reddit-db" | ||
} | ||
|
||
resources { | ||
core_fraction = 20 | ||
cores = 2 | ||
memory = 2 | ||
} | ||
|
||
boot_disk { | ||
initialize_params { | ||
image_id = var.db_disk_image | ||
} | ||
} | ||
|
||
network_interface { | ||
subnet_id = var.subnet_id | ||
nat = true | ||
} | ||
|
||
metadata = { | ||
ssh-keys = "ubuntu:${file(var.public_key_path)}" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
output "external_ip_address_db" { | ||
value = yandex_compute_instance.db.network_interface.0.nat_ip_address | ||
} | ||
#value = yandex_compute_instance.db.*.network_interface.0.ip_address | ||
#} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
variable "public_key_path" { | ||
# Описание переменной | ||
description = "Path to the public key used for ssh access" | ||
} | ||
variable "subnet_id" { | ||
description = "Subnet" | ||
} | ||
variable db_disk_image { | ||
description = "Disk image for reddit db" | ||
default = "reddit-db-base" | ||
} | ||
variable "zone" { | ||
description = "Zone" | ||
# Значение по умолчанию | ||
default = "ru-central1-a" | ||
} | ||
variable "cloud_id" { | ||
description = "Cloud" | ||
} | ||
variable "service_account_key_file" { | ||
description = "key.json" | ||
} | ||
variable "folder_id" { | ||
description = "Folder" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "yandex_vpc_network" "app-network" { | ||
name = "app-network" | ||
} | ||
resource "yandex_vpc_subnet" "app-subnet" { | ||
name = "app-subnet" | ||
zone = "ru-central1-a" | ||
network_id = "${yandex_vpc_network.app-network.id}" | ||
v4_cidr_blocks = ["192.168.10.0/24"] | ||
} |