initial commit
This commit is contained in:
parent
b6407b5718
commit
844d29a51b
1 changed files with 88 additions and 0 deletions
88
main.tf
Normal file
88
main.tf
Normal file
|
@ -0,0 +1,88 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
yandex = {
|
||||
source = "yandex-cloud/yandex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "yandex" {
|
||||
zone = "ru-central1-b"
|
||||
}
|
||||
|
||||
resource "yandex_compute_instance" "vm" {
|
||||
count = 2
|
||||
name = "vm${count.index}"
|
||||
platform_id = "standard-v1"
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image_id = "fd8gp9bblb0vpvqtch1k" # lemp
|
||||
size = 5
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
subnet_id = yandex_vpc_subnet.subnet-1.id
|
||||
nat = true
|
||||
}
|
||||
|
||||
resources {
|
||||
core_fraction = 5
|
||||
cores = 2
|
||||
memory = 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
resource "yandex_vpc_network" "network-1" {
|
||||
name = "network-1"
|
||||
}
|
||||
|
||||
|
||||
|
||||
resource "yandex_vpc_subnet" "subnet-1" {
|
||||
name = "subnet-1"
|
||||
v4_cidr_blocks = [ "172.24.8.0/24"]
|
||||
network_id = yandex_vpc_network.network-1.id
|
||||
}
|
||||
|
||||
|
||||
|
||||
resource "yandex_lb_target_group" "demo-1" {
|
||||
name = "demo-1"
|
||||
target {
|
||||
subnet_id = yandex_vpc_subnet.subnet-1.id
|
||||
address = yandex_compute_instance.vm[0].network_interface.0.ip_address
|
||||
}
|
||||
|
||||
target {
|
||||
subnet_id = yandex_vpc_subnet.subnet-1.id
|
||||
address = yandex_compute_instance.vm[1].network_interface.0.ip_address
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
resource "yandex_lb_network_load_balancer" "lb-1" {
|
||||
name = "lb-1"
|
||||
deletion_protection = "false"
|
||||
listener {
|
||||
name = "my-lb1"
|
||||
port = 80
|
||||
external_address_spec {
|
||||
ip_version = "ipv4"
|
||||
}
|
||||
}
|
||||
|
||||
attached_target_group {
|
||||
target_group_id = yandex_lb_target_group.demo-1.id
|
||||
healthcheck {
|
||||
name = "http"
|
||||
http_options {
|
||||
port = 80
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue