-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbots.tf
More file actions
135 lines (120 loc) · 4.92 KB
/
bots.tf
File metadata and controls
135 lines (120 loc) · 4.92 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Virtual Network for Bots
resource "azurerm_virtual_network" "bots_vnet" {
name = "bots-vnet"
location = "West US" # Can change: Modify location as needed
resource_group_name = "testingcncbotnet" # Must change: Replace with your resource group name
address_space = ["10.2.0.0/16"] # Can change: Modify IP range if needed
}
# Subnet for Bots
resource "azurerm_subnet" "bots_subnet" {
name = "bots-subnet"
resource_group_name = azurerm_virtual_network.bots_vnet.resource_group_name
virtual_network_name = azurerm_virtual_network.bots_vnet.name
address_prefixes = ["10.2.1.0/24"] # Can change: Modify subnet range if needed
}
# Public IPs for Bots
resource "azurerm_public_ip" "bots_public_ip" {
count = 2
name = "bot-public-ip-${count.index}"
location = "West US" # Can change: Modify location as needed
resource_group_name = "testingcncbotnet" # Must change: Replace with your resource group name
allocation_method = "Static"
}
# NSG for Bots (Allow SSH)
resource "azurerm_network_security_group" "bots_nsg" {
name = "bots-nsg"
location = "West US" # Can change: Modify location as needed
resource_group_name = "testingcncbotnet" # Must change: Replace with your resource group name
security_rule {
name = "AllowSSH"
priority = 1001
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "22"
source_address_prefix = "*"
destination_address_prefix = "*"
}
security_rule {
name = "AllowHTTPS"
priority = 1002
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "*"
destination_address_prefix = "*"
}
security_rule {
name = "AllowAnyCustom8000Inbound"
priority = 1012
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "8000"
source_address_prefix = "*"
destination_address_prefix = "*"
}
security_rule {
name = "AllowAnyCustom7777Inbound"
priority = 1022
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "7777"
source_address_prefix = "*"
destination_address_prefix = "*"
}
}
# Network Interfaces for Bots
resource "azurerm_network_interface" "bots_nic" {
count = 2
name = "bot-nic-${count.index}"
location = "West US" # Can change: Modify location as needed
resource_group_name = "testingcncbotnet" # Must change: Replace with your resource group name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.bots_subnet.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.bots_public_ip[count.index].id
}
}
# Associate NSG with Bot NICs
resource "azurerm_network_interface_security_group_association" "bots_nsg_assoc" {
count = 2
network_interface_id = azurerm_network_interface.bots_nic[count.index].id
network_security_group_id = azurerm_network_security_group.bots_nsg.id
}
# Bot Virtual Machines
resource "azurerm_virtual_machine" "bots_vm" {
count = 2
name = "bot-vm-${count.index}"
location = "West US" # Can change: Modify location as needed
resource_group_name = "testingcncbotnet" # Must change: Replace with your resource group name
network_interface_ids = [azurerm_network_interface.bots_nic[count.index].id]
vm_size = "Standard_B1s" # Can change: Modify Size as needed
storage_os_disk {
name = "bot-disk-${count.index}"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
storage_image_reference {
publisher = "canonical"
offer = "ubuntu-24_04-lts"
sku = "server"
version = "latest"
}
os_profile {
computer_name = "bot-vm-${count.index}"
admin_username = "azureuser" # Can change: Modify username as needed
admin_password = "YourStrongPassword123!" # Can change: password location as needed
}
os_profile_linux_config {
disable_password_authentication = false
}
}