-
Notifications
You must be signed in to change notification settings - Fork 130
/
main.tf
81 lines (65 loc) · 2.09 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
##########
#terraform {
# backend "s3" {}
#}
##########
# provider
##########
provider "yandex" {
# Use service_account_key_file or token
# service_account_key_file = "${var.service_account_key_file}"
token = "${var.token}"
cloud_id = "${var.cloud_id}"
folder_id = "${var.folder_id}"
}
##########
# network
##########
resource "yandex_vpc_network" "vpc_ad" {
name = "${var.vpc_name}"
}
resource "yandex_vpc_subnet" "subnet_ad" {
count = "${length(var.zone_names)}"
name = "${var.subnet_name}-${element(var.zone_short_names, count.index)}"
zone = "${element(var.zone_names, count.index)}"
v4_cidr_blocks = ["${cidrsubnet("${var.subnet_cidr}", 8, count.index)}"]
network_id = "${yandex_vpc_network.vpc_ad.id}"
}
##########
# instance
##########
data "yandex_compute_image" "win16" {
family = "${var.boot_disk_image_family}"
}
resource "yandex_compute_instance" "ad" {
count = "${var.number}"
name = "${element(var.zone_short_names, count.index)}-${var.name}${floor((count.index) / length(var.zone_names)) + 1}"
hostname = "${element(var.zone_short_names, count.index)}-${var.name}${floor((count.index) / length(var.zone_names)) + 1}"
zone = "${element(var.zone_names, count.index)}"
resources {
cores = "${var.cores}"
memory = "${var.memory}"
}
boot_disk {
initialize_params {
image_id = "${data.yandex_compute_image.win16.id}"
size = "${var.boot_disk_size}"
}
}
network_interface {
subnet_id = "${element(yandex_vpc_subnet.subnet_ad.*.id, count.index)}"
}
metadata {
user = "${var.user}"
pass = "${var.pass}"
user-data = "${local._user_data}"
deploy = "${count.index == 0 ? local._deploy_root : local._deploy_dc }"
domainname = "${var.ad_domainname}"
smadminpass = "${var.ad_smadminpass}"
forestroot = "${element(var.zone_short_names, 0)}-${var.name}1"
cidrs = "${join(",", yandex_vpc_subnet.subnet_ad.*.v4_cidr_blocks.0)}"
sites = "${join(",",var.zone_names)}"
}
}