This repository has been archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbroker.tf
63 lines (56 loc) · 2.11 KB
/
broker.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
resource "oci_core_instance" "broker" {
display_name = "broker-${count.index}"
compartment_id = var.compartment_ocid
availability_domain = local.availability_domain
shape = var.broker["shape"]
subnet_id = oci_core_subnet.subnet.id
fault_domain = "FAULT-DOMAIN-${count.index % 3 + 1}"
source_details {
source_id = var.images[var.region]
source_type = "image"
}
create_vnic_details {
subnet_id = oci_core_subnet.subnet.id
hostname_label = "broker-${count.index}"
}
metadata = {
ssh_authorized_keys = var.ssh_public_key
user_data = base64encode(
join(
"\n",
[
"#!/usr/bin/env bash",
"version=${var.confluent["version"]}",
"edition=${var.confluent["edition"]}",
"zookeeperNodeCount=${var.zookeeper["node_count"]}",
"brokerNodeCount=${var.broker["node_count"]}",
"brokerDiskCount=${var.broker["disk_count"]}",
"schemaRegistryNodeCount=${var.schema_registry["node_count"]}",
file("../scripts/firewall.sh"),
file("../scripts/install.sh"),
file("../scripts/disks.sh"),
file("../scripts/kafka_deploy_helper.sh"),
file("../scripts/broker.sh"),
],
),
)
}
count = var.broker["node_count"]
}
resource "oci_core_volume" "broker" {
count = var.broker["node_count"] * var.broker["disk_count"]
availability_domain = local.availability_domain
compartment_id = var.compartment_ocid
display_name = "broker${count.index % var.broker["node_count"]}-volume${floor(count.index / var.broker["node_count"])}"
size_in_gbs = var.broker["disk_size"]
}
resource "oci_core_volume_attachment" "broker" {
count = var.broker["node_count"] * var.broker["disk_count"]
attachment_type = "iscsi"
compartment_id = var.compartment_ocid
instance_id = oci_core_instance.broker[count.index % var.broker["node_count"]].id
volume_id = oci_core_volume.broker[count.index].id
}
output "broker_public_ips" {
value = join(",", oci_core_instance.broker.*.public_ip)
}