|
| 1 | +resource "oci_core_vcn" "vcn" { |
| 2 | + #Required |
| 3 | + compartment_id = var.compartment_ocid |
| 4 | + |
| 5 | + #Optional |
| 6 | + cidr_blocks = var.cidr_blocks |
| 7 | + display_name = "${var.cluster_name}-vcn" |
| 8 | + freeform_tags = local.common_labels |
| 9 | + is_ipv6enabled = true |
| 10 | +} |
| 11 | +resource "oci_core_subnet" "subnet" { |
| 12 | + #Required |
| 13 | + cidr_block = var.subnet_block |
| 14 | + compartment_id = var.compartment_ocid |
| 15 | + vcn_id = oci_core_vcn.vcn.id |
| 16 | + prohibit_internet_ingress = false |
| 17 | + prohibit_public_ip_on_vnic = false |
| 18 | + |
| 19 | + #Optional |
| 20 | + display_name = "${var.cluster_name}-subnet" |
| 21 | + freeform_tags = local.common_labels |
| 22 | + security_list_ids = [oci_core_security_list.security_list.id] |
| 23 | + route_table_id = oci_core_route_table.route_table.id |
| 24 | +} |
| 25 | +resource "oci_core_subnet" "node_subnet" { |
| 26 | + #Required |
| 27 | + cidr_block = var.node_subnet_block |
| 28 | + compartment_id = var.compartment_ocid |
| 29 | + vcn_id = oci_core_vcn.vcn.id |
| 30 | + prohibit_internet_ingress = false |
| 31 | + prohibit_public_ip_on_vnic = false |
| 32 | + |
| 33 | + #Optional |
| 34 | + display_name = "${var.cluster_name}-subnet" |
| 35 | + freeform_tags = local.common_labels |
| 36 | + security_list_ids = [oci_core_security_list.security_list.id] |
| 37 | + route_table_id = oci_core_route_table.route_table.id |
| 38 | +} |
| 39 | +resource "oci_core_route_table" "route_table" { |
| 40 | + #Required |
| 41 | + compartment_id = var.compartment_ocid |
| 42 | + vcn_id = oci_core_vcn.vcn.id |
| 43 | + |
| 44 | + #Optional |
| 45 | + display_name = "${var.cluster_name}-route-table" |
| 46 | + freeform_tags = local.common_labels |
| 47 | + route_rules { |
| 48 | + #Required |
| 49 | + network_entity_id = oci_core_internet_gateway.internet_gateway.id |
| 50 | + |
| 51 | + #Optional |
| 52 | + destination_type = "CIDR_BLOCK" |
| 53 | + destination = "0.0.0.0/0" |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +resource "oci_core_internet_gateway" "internet_gateway" { |
| 58 | + #Required |
| 59 | + compartment_id = var.compartment_ocid |
| 60 | + vcn_id = oci_core_vcn.vcn.id |
| 61 | + |
| 62 | + #Optional |
| 63 | + enabled = true |
| 64 | + display_name = "${var.cluster_name}-internet-gateway" |
| 65 | + freeform_tags = local.common_labels |
| 66 | +} |
| 67 | + |
| 68 | +resource "oci_core_network_security_group" "network_security_group" { |
| 69 | + #Required |
| 70 | + compartment_id = var.compartment_ocid |
| 71 | + vcn_id = oci_core_vcn.vcn.id |
| 72 | + |
| 73 | + #Optional |
| 74 | + display_name = "${var.cluster_name}-security-group" |
| 75 | + freeform_tags = local.common_labels |
| 76 | +} |
| 77 | +resource "oci_core_network_security_group_security_rule" "allow_all" { |
| 78 | + network_security_group_id = oci_core_network_security_group.network_security_group.id |
| 79 | + destination_type = "CIDR_BLOCK" |
| 80 | + destination = "0.0.0.0/0" |
| 81 | + protocol = "all" |
| 82 | + direction = "EGRESS" |
| 83 | + stateless = false |
| 84 | +} |
| 85 | + |
| 86 | +resource "oci_core_security_list" "security_list" { |
| 87 | + #Required |
| 88 | + compartment_id = var.compartment_ocid |
| 89 | + vcn_id = oci_core_vcn.vcn.id |
| 90 | + |
| 91 | + #Optional |
| 92 | + display_name = "${var.cluster_name}-security-list" |
| 93 | + egress_security_rules { |
| 94 | + #Required |
| 95 | + destination = "0.0.0.0/0" |
| 96 | + protocol = "all" |
| 97 | + |
| 98 | + stateless = true |
| 99 | + } |
| 100 | + freeform_tags = local.common_labels |
| 101 | + ingress_security_rules { |
| 102 | + #Required |
| 103 | + source = "0.0.0.0/0" |
| 104 | + protocol = "all" |
| 105 | + |
| 106 | + stateless = true |
| 107 | + } |
| 108 | +} |
0 commit comments