-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
116 lines (99 loc) · 3.57 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
subscription_id = "be868bd4-3bf7-4511-8065-c4a0917fa077"
skip_provider_registration = true
}
terraform {
backend "remote" {
organization = "myshka"
workspaces {
name = "automation_platform"
}
}
}
resource "azurerm_resource_group" "automation_platform" {
location = "eastus2"
name = "automation_platform"
tags = {}
timeouts {}
}
resource "azurerm_virtual_network" "automation_platform_vnet" {
address_space = [
"10.0.0.0/16",
]
location = azurerm_resource_group.automation_platform.location
name = "automation_platform-vnet"
resource_group_name = azurerm_resource_group.automation_platform.name
}
resource "azurerm_subnet" "automation_platform_subnet" {
address_prefixes = [
"10.0.0.0/24",
]
enforce_private_link_endpoint_network_policies = false
enforce_private_link_service_network_policies = false
name = "auto-platform-cluster"
resource_group_name = azurerm_resource_group.automation_platform.name
virtual_network_name = azurerm_virtual_network.automation_platform_vnet.name
timeouts {}
}
resource "azurerm_public_ip" "automation_platform_pub" {
count = var.server_count
allocation_method = "Dynamic"
availability_zone = "No-Zone"
idle_timeout_in_minutes = 4
ip_version = "IPv4"
location = azurerm_resource_group.automation_platform.location
name = "${var.vm_prefix}${format("%02d", count.index)}-pubip"
resource_group_name = azurerm_resource_group.automation_platform.name
sku = "Basic"
timeouts {}
}
resource "azurerm_network_interface" "automation_platform_nic" {
count = var.server_count
enable_accelerated_networking = false
location = azurerm_resource_group.automation_platform.location
name = "${var.vm_prefix}${format("%02d", count.index)}-nic"
resource_group_name = azurerm_resource_group.automation_platform.name
ip_configuration {
name = "ipconfig1"
primary = true
private_ip_address_allocation = "Dynamic"
private_ip_address_version = "IPv4"
public_ip_address_id = element(azurerm_public_ip.automation_platform_pub.*.id, count.index)
subnet_id = azurerm_subnet.automation_platform_subnet.id
}
timeouts {}
}
resource "azurerm_linux_virtual_machine" "automation_platform_server" {
count = var.server_count
location = azurerm_resource_group.automation_platform.location
name = "${var.vm_prefix}${format("%02d", count.index)}-vm"
admin_username = var.admin_username
network_interface_ids = [
element(azurerm_network_interface.automation_platform_nic.*.id, count.index),
]
resource_group_name = azurerm_resource_group.automation_platform.name
size = "Standard_D2s_v3"
admin_ssh_key {
username = var.admin_username
public_key = file("files/wsl_home_id_rsa.pub")
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Premium_LRS"
}
source_image_reference {
offer = "RHEL"
publisher = "RedHat"
sku = "8_4"
version = "latest"
}
timeouts {}
}
output "vm_ip_addresses" {
value = {
for vm in azurerm_linux_virtual_machine.automation_platform_server:
vm.name => vm.public_ip_address
}
}