This repository has been archived by the owner on May 13, 2024. It is now read-only.
generated from oracle-quickstart/oci-quickstart-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcompute.tf
126 lines (102 loc) · 3.59 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
## Copyright © 2020, Oracle and/or its affiliates.
## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
data "template_file" "key_script" {
template = file("./scripts/sshkey.tpl")
vars = {
ssh_public_key = tls_private_key.public_private_key_pair.public_key_openssh
}
}
data "template_cloudinit_config" "cloud_init" {
gzip = true
base64_encode = true
part {
filename = "ainit.sh"
content_type = "text/x-shellscript"
content = data.template_file.key_script.rendered
}
}
# Bastion VM
resource "oci_core_instance" "bastion_instance" {
availability_domain = var.availablity_domain_name
compartment_id = var.compartment_ocid
display_name = "BastionVM"
shape = var.InstanceShape
dynamic "shape_config" {
for_each = local.is_flexible_node_shape ? [1] : []
content {
memory_in_gbs = var.InstanceFlexShapeMemory
ocpus = var.InstanceFlexShapeOCPUS
}
}
create_vnic_details {
subnet_id = oci_core_subnet.hub_subnet_pub01.id
display_name = "primaryvnic"
assign_public_ip = true
}
source_details {
source_type = "image"
source_id = data.oci_core_images.InstanceImageOCID.images[0].id
boot_volume_size_in_gbs = "50"
}
metadata = {
ssh_authorized_keys = var.ssh_public_key
user_data = data.template_cloudinit_config.cloud_init.rendered
}
defined_tags = {"${oci_identity_tag_namespace.ArchitectureCenterTagNamespace.name}.${oci_identity_tag.ArchitectureCenterTag.name}" = var.release }
}
resource "oci_core_instance" "spoke01_test_instance" {
count = var.deploy_spoke01_instance ? 1 : 0
availability_domain = var.availablity_domain_name
compartment_id = var.compartment_ocid
display_name = "spoke01_test_instance"
shape = var.InstanceShapeSpoke01
dynamic "shape_config" {
for_each = local.is_flexible_node_shape_spoke01 ? [1] : []
content {
memory_in_gbs = var.InstanceFlexShapeMemorySpoke01
ocpus = var.InstanceFlexShapeOCPUSSpoke01
}
}
create_vnic_details {
subnet_id = oci_core_subnet.spoke01_subnet_priv01.id
display_name = "primaryvnic"
assign_public_ip = false
}
source_details {
source_type = "image"
source_id = data.oci_core_images.InstanceImageOCID.images[0].id
boot_volume_size_in_gbs = "50"
}
metadata = {
ssh_authorized_keys = var.ssh_public_key
user_data = data.template_cloudinit_config.cloud_init.rendered
}
}
resource "oci_core_instance" "spoke02_test_instance" {
count = var.deploy_spoke01_instance ? 1 : 0
availability_domain = var.availablity_domain_name
compartment_id = var.compartment_ocid
display_name = "spoke02_test_instance"
shape = var.InstanceShapeSpoke02
dynamic "shape_config" {
for_each = local.is_flexible_node_shape_spoke02 ? [1] : []
content {
memory_in_gbs = var.InstanceFlexShapeMemorySpoke02
ocpus = var.InstanceFlexShapeOCPUSSpoke02
}
}
create_vnic_details {
subnet_id = oci_core_subnet.spoke02_subnet_priv01.id
display_name = "primaryvnic"
assign_public_ip = false
}
source_details {
source_type = "image"
source_id = data.oci_core_images.InstanceImageOCID.images[0].id
boot_volume_size_in_gbs = "50"
}
metadata = {
ssh_authorized_keys = var.ssh_public_key
user_data = data.template_cloudinit_config.cloud_init.rendered
}
}