forked from SureshProgrammer/oracle-bmc-terraform-dse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute.tf
176 lines (159 loc) · 7.04 KB
/
compute.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Compute resources
resource "oci_core_instance" "DSE_OPSC" {
provider = "oci.phx"
depends_on = ["oci_core_subnet.DataStax_PublicSubnet_AD_PHX"]
availability_domain = "${lookup(data.oci_identity_availability_domains.PHX_ADs.availability_domains[0],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "OPSC_AD_1-0"
image = "${lookup(data.oci_core_images.OLImageOCID_PHX.images[0], "id")}"
shape = "${var.OPSC_Shape}"
subnet_id = "${oci_core_subnet.DataStax_PublicSubnet_AD_PHX.0.id}"
metadata {
ssh_authorized_keys = "${var.ssh_public_key}"
user_data = "${base64encode(format("%s\n%s %s %s %s %s %s %s %s %s\n",
file(var.OPSC_BootStrap),
"./lcm_opscenter.sh",
"${var.DSE_Cluster_Name}",
"${var.DSE_Cluster_Topology_PHX_Region["AD1_Count"] +
var.DSE_Cluster_Topology_PHX_Region["AD2_Count"] +
var.DSE_Cluster_Topology_PHX_Region["AD3_Count"] +
var.DSE_Cluster_Topology_IAD_Region["AD1_Count"] +
var.DSE_Cluster_Topology_IAD_Region["AD2_Count"] +
var.DSE_Cluster_Topology_IAD_Region["AD3_Count"]}",
"${length(var.regions)}",
"${var.host_user_name}",
"${var.DataStax_Academy_Creds["username"]}",
"${var.DataStax_Academy_Creds["password"]}",
"${var.Cassandra_DB_User_Password}",
"${var.OpsCenter_Admin_Password}"
))}"
}
}
# PHX (Phoenix region)
resource "oci_core_instance" "DSE_Node_PHX_0" {
provider = "oci.phx"
depends_on = ["oci_core_instance.DSE_OPSC"]
availability_domain = "${lookup(data.oci_identity_availability_domains.PHX_ADs.availability_domains[0],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "${format("DSE_AD_PHX_1-%d", count.index)}"
image = "${lookup(data.oci_core_images.OLImageOCID_PHX.images[0], "id")}"
shape = "${var.DSE_Shape}"
subnet_id = "${oci_core_subnet.DataStax_PublicSubnet_AD_PHX.0.id}"
metadata {
ssh_authorized_keys = "${var.ssh_public_key}"
user_data = "${base64encode(format("%s\n%s %s %s %s\n",
file(var.DSE_BootStrap),
"./lcm_node.sh",
"${data.oci_core_vnic.DSE_OPSC_Vnic.public_ip_address}",
"${var.DSE_Cluster_Name}",
"us-phoenix-1"
))}"
}
count = "${var.DSE_Cluster_Topology_PHX_Region["AD1_Count"]}"
}
resource "oci_core_instance" "DSE_Node_PHX_1" {
provider = "oci.phx"
depends_on = ["oci_core_instance.DSE_OPSC"]
availability_domain = "${lookup(data.oci_identity_availability_domains.PHX_ADs.availability_domains[1],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "${format("DSE_AD_PHX_2-%d", count.index)}"
image = "${lookup(data.oci_core_images.OLImageOCID_PHX.images[0], "id")}"
shape = "${var.DSE_Shape}"
subnet_id = "${oci_core_subnet.DataStax_PublicSubnet_AD_PHX.1.id}"
metadata {
ssh_authorized_keys = "${var.ssh_public_key}"
user_data = "${base64encode(format("%s\n%s %s %s %s\n",
file(var.DSE_BootStrap),
"./lcm_node.sh",
"${data.oci_core_vnic.DSE_OPSC_Vnic.public_ip_address}",
"${var.DSE_Cluster_Name}",
"us-phoenix-1"
))}"
}
count = "${var.DSE_Cluster_Topology_PHX_Region["AD2_Count"]}"
}
resource "oci_core_instance" "DSE_Node_PHX_2" {
provider = "oci.phx"
depends_on = ["oci_core_instance.DSE_OPSC"]
availability_domain = "${lookup(data.oci_identity_availability_domains.PHX_ADs.availability_domains[2],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "${format("DSE_AD_PHX_3-%d", count.index)}"
image = "${lookup(data.oci_core_images.OLImageOCID_PHX.images[0], "id")}"
shape = "${var.DSE_Shape}"
subnet_id = "${oci_core_subnet.DataStax_PublicSubnet_AD_PHX.2.id}"
metadata {
ssh_authorized_keys = "${var.ssh_public_key}"
user_data = "${base64encode(format("%s\n%s %s %s %s\n",
file(var.DSE_BootStrap),
"./lcm_node.sh",
"${data.oci_core_vnic.DSE_OPSC_Vnic.public_ip_address}",
"${var.DSE_Cluster_Name}",
"us-phoenix-1"
))}"
}
count = "${var.DSE_Cluster_Topology_PHX_Region["AD3_Count"]}"
}
# IAD (Ashburn region)
resource "oci_core_instance" "DSE_Node_IAD_0" {
provider = "oci.iad"
depends_on = ["oci_core_instance.DSE_OPSC"]
availability_domain = "${lookup(data.oci_identity_availability_domains.IAD_ADs.availability_domains[0],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "${format("DSE_AD_IAD_1-%d", count.index)}"
image = "${lookup(data.oci_core_images.OLImageOCID_IAD.images[0], "id")}"
shape = "${var.DSE_Shape}"
subnet_id = "${oci_core_subnet.DataStax_PublicSubnet_AD_IAD.0.id}"
metadata {
ssh_authorized_keys = "${var.ssh_public_key}"
user_data = "${base64encode(format("%s\n%s %s %s %s\n",
file(var.DSE_BootStrap),
"./lcm_node.sh",
"${data.oci_core_vnic.DSE_OPSC_Vnic.public_ip_address}",
"${var.DSE_Cluster_Name}",
"us-ashburn-1"
))}"
}
count = "${var.DSE_Cluster_Topology_IAD_Region["AD1_Count"]}"
}
resource "oci_core_instance" "DSE_Node_IAD_1" {
provider = "oci.iad"
depends_on = ["oci_core_instance.DSE_OPSC"]
availability_domain = "${lookup(data.oci_identity_availability_domains.IAD_ADs.availability_domains[1],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "${format("DSE_AD_IAD_2-%d", count.index)}"
image = "${lookup(data.oci_core_images.OLImageOCID_IAD.images[0], "id")}"
shape = "${var.DSE_Shape}"
subnet_id = "${oci_core_subnet.DataStax_PublicSubnet_AD_IAD.1.id}"
metadata {
ssh_authorized_keys = "${var.ssh_public_key}"
user_data = "${base64encode(format("%s\n%s %s %s %s\n",
file(var.DSE_BootStrap),
"./lcm_node.sh",
"${data.oci_core_vnic.DSE_OPSC_Vnic.public_ip_address}",
"${var.DSE_Cluster_Name}",
"us-ashburn-1"
))}"
}
count = "${var.DSE_Cluster_Topology_IAD_Region["AD2_Count"]}"
}
resource "oci_core_instance" "DSE_Node_IAD_2" {
provider = "oci.iad"
depends_on = ["oci_core_instance.DSE_OPSC"]
availability_domain = "${lookup(data.oci_identity_availability_domains.IAD_ADs.availability_domains[2],"name")}"
compartment_id = "${var.compartment_ocid}"
display_name = "${format("DSE_AD_IAD_3-%d", count.index)}"
image = "${lookup(data.oci_core_images.OLImageOCID_IAD.images[0], "id")}"
shape = "${var.DSE_Shape}"
subnet_id = "${oci_core_subnet.DataStax_PublicSubnet_AD_IAD.2.id}"
metadata {
ssh_authorized_keys = "${var.ssh_public_key}"
user_data = "${base64encode(format("%s\n%s %s %s %s\n",
file(var.DSE_BootStrap),
"./lcm_node.sh",
"${data.oci_core_vnic.DSE_OPSC_Vnic.public_ip_address}",
"${var.DSE_Cluster_Name}",
"us-ashburn-1"
))}"
}
count = "${var.DSE_Cluster_Topology_IAD_Region["AD3_Count"]}"
}