-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompute.tf
executable file
·41 lines (34 loc) · 1.71 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
# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
resource "oci_core_instance" "app_instance" {
availability_domain = random_shuffle.compute_ad.result[count.index % length(random_shuffle.compute_ad.result)]
compartment_id = var.compartment_ocid
display_name = "DotNet-${random_string.deploy_id.result}-${count.index}"
shape = var.instance_shape
freeform_tags = local.common_tags
create_vnic_details {
subnet_id = oci_core_subnet.dotnet_main_subnet.id
display_name = "primaryvnic"
assign_public_ip = (var.instance_visibility == "Private") ? false : true
hostname_label = "dotnet-${random_string.deploy_id.result}-${count.index}"
}
source_details {
source_type = "image"
source_id = lookup(data.oci_core_images.compute_images.images[0], "id")
}
metadata = {
ssh_authorized_keys = var.generate_public_ssh_key ? tls_private_key.compute_ssh_key.public_key_openssh : var.public_ssh_key
user_data = data.template_cloudinit_config.instances.rendered
}
count = var.num_instances
}
### Important Security Notice ###
# The private key generated by this resource will be stored unencrypted in your Terraform state file.
# Use of this resource for production deployments is not recommended.
# Instead, generate a private key file outside of Terraform and distribute it securely to the system where Terraform will be run.
# Generate ssh keys to access Compute Nodes, if generate_public_ssh_key=true, applies to the Compute
resource "tls_private_key" "compute_ssh_key" {
algorithm = "RSA"
rsa_bits = 2048
}