|
| 1 | +// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + |
| 3 | +variable "tenancy_ocid" {} |
| 4 | +variable "user_ocid" {} |
| 5 | +variable "fingerprint" {} |
| 6 | +variable "private_key_path" {} |
| 7 | +variable "region" {} |
| 8 | +variable "compartment_ocid" {} |
| 9 | + |
| 10 | +provider "oci" { |
| 11 | + tenancy_ocid = "${var.tenancy_ocid}" |
| 12 | + user_ocid = "${var.user_ocid}" |
| 13 | + fingerprint = "${var.fingerprint}" |
| 14 | + private_key_path = "${var.private_key_path}" |
| 15 | + region = "${var.region}" |
| 16 | +} |
| 17 | + |
| 18 | +data "oci_identity_availability_domains" "test_availability_domains" { |
| 19 | + compartment_id = "${var.tenancy_ocid}" |
| 20 | +} |
| 21 | + |
| 22 | +resource "oci_core_vcn" "test_vcn" { |
| 23 | + cidr_block = "10.0.0.0/16" |
| 24 | + compartment_id = "${var.compartment_ocid}" |
| 25 | + display_name = "TestVcn" |
| 26 | + dns_label = "dnslabel" |
| 27 | +} |
| 28 | + |
| 29 | +resource "oci_core_route_table" "test_route_table" { |
| 30 | + compartment_id = "${var.compartment_id}" |
| 31 | + vcn_id = "${oci_core_vcn.test_vcn.id}" |
| 32 | + display_name = "TestRouteTable" |
| 33 | +} |
| 34 | + |
| 35 | +resource "oci_core_subnet" "test_subnet" { |
| 36 | + availability_domain = "${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}" |
| 37 | + cidr_block = "10.0.2.0/24" |
| 38 | + compartment_id = "${var.compartment_id}" |
| 39 | + dhcp_options_id = "${oci_core_vcn.test_vcn.default_dhcp_options_id}" |
| 40 | + display_name = "TestSubnet" |
| 41 | + dns_label = "dnslabel" |
| 42 | + route_table_id = "${oci_core_route_table.test_route_table.id}" |
| 43 | + security_list_ids = ["${oci_core_vcn.test_vcn.default_security_list_id}"] |
| 44 | + vcn_id = "${oci_core_vcn.test_vcn.id}" |
| 45 | +} |
| 46 | + |
| 47 | +variable "InstanceImageOCID" { |
| 48 | + type = "map" |
| 49 | + |
| 50 | + default = { |
| 51 | + // See https://docs.us-phoenix-1.oraclecloud.com/images/ |
| 52 | + // Oracle-provided image "Oracle-Linux-7.5-2018.10.16-0" |
| 53 | + us-phoenix-1 = "ocid1.image.oc1.phx.aaaaaaaadjnj3da72bztpxinmqpih62c2woscbp6l3wjn36by2cvmdhjub6a" |
| 54 | + |
| 55 | + us-ashburn-1 = "ocid1.image.oc1.iad.aaaaaaaawufnve5jxze4xf7orejupw5iq3pms6cuadzjc7klojix6vmk42va" |
| 56 | + eu-frankfurt-1 = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaagbrvhganmn7awcr7plaaf5vhabmzhx763z5afiitswjwmzh7upna" |
| 57 | + uk-london-1 = "ocid1.image.oc1.uk-london-1.aaaaaaaajwtut4l7fo3cvyraate6erdkyf2wdk5vpk6fp6ycng3dv2y3ymvq" |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +resource "oci_core_network_security_group" "test_network_security_group1" { |
| 62 | + compartment_id = "${var.compartment_id}" |
| 63 | + vcn_id = "${oci_core_vcn.test_vcn.id}" |
| 64 | +} |
| 65 | + |
| 66 | +resource "oci_core_instance_configuration" "test_instance_configuration" { |
| 67 | + compartment_id = "${var.compartment_ocid}" |
| 68 | + display_name = "TestInstanceConfiguration" |
| 69 | + |
| 70 | + instance_details { |
| 71 | + instance_type = "compute" |
| 72 | + |
| 73 | + launch_details { |
| 74 | + availability_domain = "${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}" |
| 75 | + compartment_id = "${var.compartment_id}" |
| 76 | + |
| 77 | + create_vnic_details { |
| 78 | + assign_public_ip = "false" |
| 79 | + display_name = "backend-servers" |
| 80 | + hostname_label = "hostnameLabel" |
| 81 | + nsg_ids = ["${oci_core_network_security_group.test_network_security_group1.id}"] |
| 82 | + private_ip = "privateIp" |
| 83 | + skip_source_dest_check = "false" |
| 84 | + subnet_id = "${oci_core_subnet.test_subnet.id}" |
| 85 | + } |
| 86 | + |
| 87 | + display_name = "backend-servers" |
| 88 | + |
| 89 | + extended_metadata = { |
| 90 | + "extendedMetadata" = "extendedMetadata" |
| 91 | + } |
| 92 | + |
| 93 | + fault_domain = "FAULT-DOMAIN-2" |
| 94 | + |
| 95 | + ipxe_script = "ipxeScript" |
| 96 | + |
| 97 | + metadata = { |
| 98 | + "metadata" = "metadata" |
| 99 | + } |
| 100 | + |
| 101 | + shape = "BM.HPC2.36" |
| 102 | + |
| 103 | + source_details { |
| 104 | + boot_volume_size_in_gbs = "55" |
| 105 | + image_id = "${var.InstanceImageOCID[var.region]}" |
| 106 | + source_type = "image" |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + source = "NONE" |
| 112 | +} |
| 113 | + |
| 114 | +resource "oci_core_cluster_network" "test_cluster_network" { |
| 115 | + compartment_id = "${var.compartment_id}" |
| 116 | + display_name = "hpc-cluster-network" |
| 117 | + |
| 118 | + instance_pools { |
| 119 | + display_name = "hpc-cluster-network" |
| 120 | + instance_configuration_id = "${oci_core_instance_configuration.test_instance_configuration.id}" |
| 121 | + size = "1" |
| 122 | + } |
| 123 | + |
| 124 | + placement_configuration { |
| 125 | + availability_domain = "${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}" |
| 126 | + primary_subnet_id = "${oci_core_subnet.test_subnet.id}" |
| 127 | + } |
| 128 | +} |
0 commit comments