generated from oracle-devrel/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
compute.tf
98 lines (85 loc) · 2.76 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
# Copyright (c) 2024 Oracle and/or its affiliates.
resource oci_core_instance llm_host {
availability_domain = var.availability_domain_name == "" ? data.oci_identity_availability_domains.ADs.availability_domains[0]["name"] : var.availability_domain_name
compartment_id = var.compartment_ocid
shape = var.instance_shape
defined_tags = { "${oci_identity_tag_namespace.ArchitectureCenterTagNamespace.name}.${oci_identity_tag.ArchitectureCenterTag.name}" = var.release }
agent_config {
is_management_disabled = "false"
is_monitoring_disabled = "false"
}
create_vnic_details {
assign_public_ip = "true"
display_name = "llm_host_publicip"
skip_source_dest_check = "false"
subnet_id = oci_core_subnet.subnet.id
}
display_name = "${var.app_name}_llmhost"
metadata = {
ssh_authorized_keys = local.ssh_public_keys
user_data = data.template_cloudinit_config.cloud_init.rendered
}
source_details {
source_id = lookup(data.oci_core_images.InstanceImageOCID.images[0], "id")
source_type = "image"
boot_volume_size_in_gbs = var.boot_volume_size_in_gbs
boot_volume_vpus_per_gb = var.boot_volume_vpus_per_gb
}
lifecycle {
ignore_changes = [defined_tags]
}
#-ENV Setup
connection {
agent = false
timeout = "60m"
host = oci_core_instance.llm_host.public_ip
user = "opc"
private_key = tls_private_key.tls_private_key.private_key_pem
}
provisioner "file" {
source = "scripts/setup.sh"
destination = "/home/opc/setup.sh"
connection {
private_key = tls_private_key.tls_private_key.private_key_pem
user = "opc"
host = self.public_ip
}
}
#-Copy default service
provisioner "file" {
source = "scripts/default.svc"
destination = "/home/opc/default.svc"
connection {
private_key = tls_private_key.tls_private_key.private_key_pem
user = "opc"
host = self.public_ip
}
}
#Copy openai service
provisioner "file" {
source = "scripts/openai.svc"
destination = "/home/opc/openai.svc"
connection {
private_key = tls_private_key.tls_private_key.private_key_pem
user = "opc"
host = self.public_ip
}
}
#Running Exec
provisioner "remote-exec" {
inline = [
"chmod +x /home/opc/setup.sh",
"export api_key=${random_id.api_key.id}",
"export model_path=${var.model_path}",
"export huggingface_access_token=${var.huggingface_access_token}",
"export llm_port_default=${var.default_port}",
"export llm_port_openai=${var.openai_port}",
"bash /home/opc/setup.sh"
]
connection {
private_key = tls_private_key.tls_private_key.private_key_pem
user = "opc"
host = self.public_ip
}
}
}