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 5
/
server.tf
51 lines (44 loc) · 1.59 KB
/
server.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
locals {
# If ad_number is non-negative use it for AD lookup, else use ad_name.
# Allows for use of ad_number in TF deploys, and ad_name in ORM.
# Use of max() prevents out of index lookup call.
# TESTING
#ad = "${var.ad_number >= 0 ? lookup(data.oci_identity_availability_domains.availability_domains.availability_domains[max(0,var.ad_number)],"name") : var.ad_name}"
# Logic to choose platform or mkpl image based on
# var.marketplace_image being empty or not
server_image = var.mp_listing_resource_id
}
resource "oci_core_instance" "couchbase_server" {
count = var.server_count
display_name = "couchbase_server${count.index}"
compartment_id = var.compartment_ocid
availability_domain = element(data.template_file.ad_names.*.rendered, count.index)
fault_domain = "FAULT-DOMAIN-${count.index % 3 + 1}"
shape = var.server_shape
subnet_id = oci_core_subnet.subnet.id
source_details {
source_id = local.server_image
source_type = "image"
}
create_vnic_details {
subnet_id = oci_core_subnet.subnet.id
hostname_label = "couchbase-server${count.index}"
}
metadata = {
ssh_authorized_keys = var.ssh_public_key
user_data = base64encode(
join(
"\n",
[
"#!/usr/bin/env bash",
"version=${var.server_version}",
"adminUsername=${var.adminUsername}",
"adminPassword=${var.adminPassword}",
"diskCount=${var.disk_count}",
file("../scripts/disks.sh"),
file("../scripts/server.sh"),
],
),
)
}
}