-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
81 lines (67 loc) · 1.47 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
terraform {
required_providers {
yandex = {
source = "yandex-cloud/yandex"
}
}
required_version = ">= 0.13"
}
variable "cloud_id" {
type = string
nullable = false
}
variable "folder_id" {
type = string
nullable = false
}
variable "iam_token" {
type = string
nullable = false
}
variable "preemptible" {
type = bool
default = false
description = "reduces the price twice but instance may stop suddenly"
}
provider "yandex" {
token = var.iam_token
cloud_id = var.cloud_id
folder_id = var.folder_id
zone = "ru-central1-a"
}
resource "yandex_compute_instance" "proxy_instance" {
name = "proxy"
platform_id = "standard-v3"
resources {
cores = 2
memory = 2
core_fraction = 50
}
scheduling_policy {
preemptible = var.preemptible
}
boot_disk {
auto_delete = true
initialize_params {
image_id = "fd8snjpoq85qqv0mk9gi" # Ubuntu 20.04
}
}
network_interface {
nat = true
nat_ip_address = ""
subnet_id = yandex_vpc_subnet.proxy_subnet.id
}
metadata = {
user-data = file("metadata.yml")
}
}
resource "yandex_vpc_network" "proxy_network" {
name = "proxy-network"
}
resource "yandex_vpc_subnet" "proxy_subnet" {
network_id = yandex_vpc_network.proxy_network.id
v4_cidr_blocks = ["10.5.0.0/28"]
}
output "instance_ip" {
value = yandex_compute_instance.proxy_instance.network_interface[0].nat_ip_address
}