-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkafka.tf
95 lines (77 loc) · 2.53 KB
/
kafka.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
provider "azurerm" {
version = "=2.18.0"
features {}
}
resource "azurerm_resource_group" "kafka_deployment" {
name = "kafka_lab"
location = "North Europe"
}
resource "azurerm_virtual_network" "kafka_deployment" {
name = "kafka-net"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.kafka_deployment.location
resource_group_name = azurerm_resource_group.kafka_deployment.name
}
resource "azurerm_subnet" "kafka_deployment" {
name = "kafka-subnet"
resource_group_name = azurerm_resource_group.kafka_deployment.name
virtual_network_name = azurerm_virtual_network.kafka_deployment.name
address_prefixes = ["10.0.0.0/24"]
}
resource "azurerm_public_ip" "kafka_deployment" {
count = 3
name = "kafka_public${count.index}"
resource_group_name = azurerm_resource_group.kafka_deployment.name
location = azurerm_resource_group.kafka_deployment.location
allocation_method = "Dynamic"
}
resource "azurerm_network_interface" "kafka_deployment" {
count = 3
name = "broker-nic-${count.index}"
location = azurerm_resource_group.kafka_deployment.location
resource_group_name = azurerm_resource_group.kafka_deployment.name
ip_configuration {
name = "kafkanode"
subnet_id = azurerm_subnet.kafka_deployment.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.kafka_deployment[count.index].id
}
}
resource "azurerm_virtual_machine" "kafka_deployment" {
count = 3
name = "kafka-broker-${count.index}"
location = azurerm_resource_group.kafka_deployment.location
resource_group_name = azurerm_resource_group.kafka_deployment.name
network_interface_ids = [
azurerm_network_interface.kafka_deployment[count.index].id
]
vm_size = "Standard_DS1_v2"
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "18.04-LTS"
version = "latest"
}
storage_os_disk {
name = "kafkadisk${count.index}"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "kafka-broker-${count.index}"
admin_username = "benjamin"
// admin_password = "nowebs4U!"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
key_data = file("~/.ssh/id_rsa.pub")
path = "/home/benjamin/.ssh/authorized_keys"
}
}
tags = {
environment = "kafka-lab"
role = "kafka"
}
}