-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
97 lines (76 loc) · 1.71 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
terraform {
required_providers {
yandex = {
source = "yandex-cloud/yandex"
}
}
}
provider "yandex" {
token = var.yc_token
cloud_id = var.cloud_id
folder_id = var.folder_id
zone = "ru-central1-a"
}
resource "yandex_compute_instance" "vm-1" {
name = "terraform1"
resources {
cores = 2
memory = 2
core_fraction = 5
}
boot_disk {
initialize_params {
image_id = var.image_id
size = 25
}
}
network_interface {
subnet_id = yandex_vpc_subnet.subnet-1.id
nat = true
}
metadata = {
user-data = "${file("./meta.yml")}"
}
}
resource "yandex_compute_instance" "vm-2" {
name = "terraform2"
resources {
cores = 2
memory = 2
core_fraction = 5
}
boot_disk {
initialize_params {
image_id = var.image_id
size = 25
}
}
network_interface {
subnet_id = yandex_vpc_subnet.subnet-1.id
nat = true
}
metadata = {
user-data = "${file("./meta.yml")}"
}
}
resource "yandex_vpc_network" "network-1" {
name = "network1"
}
resource "yandex_vpc_subnet" "subnet-1" {
name = "subnet1"
zone = "ru-central1-a"
network_id = yandex_vpc_network.network-1.id
v4_cidr_blocks = ["192.168.10.0/24"]
}
output "internal_ip_address_vm_1" {
value = yandex_compute_instance.vm-1.network_interface.0.ip_address
}
output "internal_ip_address_vm_2" {
value = yandex_compute_instance.vm-2.network_interface.0.ip_address
}
output "external_ip_address_vm_1" {
value = yandex_compute_instance.vm-1.network_interface.0.nat_ip_address
}
output "external_ip_address_vm_2" {
value = yandex_compute_instance.vm-2.network_interface.0.nat_ip_address
}