Skip to content

Commit 943c289

Browse files
committed
example extra subnet
Signed-off-by: junior <junior@users.noreply.github.com>
1 parent 625c22a commit 943c289

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

modules/new-subnet-from-oke-vcn/providers.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ terraform {
77
required_providers {
88
oci = {
99
source = "oracle/oci"
10-
version = ">= 4.88.1"
11-
# https://registry.terraform.io/providers/oracle/oci/4.88.1
10+
version = "~> 4"
11+
# https://registry.terraform.io/providers/oracle/oci/
1212
}
1313
}
1414
}

modules/new-subnet-from-oke-vcn/security-lists.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ resource "oci_core_security_list" "extra_subnet_security_list" {
3333
stateless = false
3434
}
3535

36-
count = var.create_new_oke_cluster ? 1 : 0
36+
count = var.create_new_subnet ? 1 : 0
3737
}
3838

3939
locals {

modules/new-subnet-from-oke-vcn/subnet.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ resource "oci_core_subnet" "extra_subnet" {
66
cidr_block = lookup(var.network_cidrs, "EXTRA-SUBNET-REGIONAL-CIDR")
77
compartment_id = var.oke_vcn_compartment_ocid
88
display_name = "${local.subnet_name_normalized}-subnet-${local.deploy_id}"
9-
dns_label = "${local.subnet_name_normalized}${local.deploy_id}"
9+
dns_label = "${local.app_name_for_dns}${local.deploy_id}"
1010
vcn_id = var.oke_vcn_ocid
1111
prohibit_public_ip_on_vnic = true
1212
route_table_id = oci_core_route_table.extra_subnet_route_table[0].id
13-
dhcp_options_id = var.oke_vcn_default_dhcp_id
13+
dhcp_options_id = var.oke_vcn_default_dhcp_ocid
1414
security_list_ids = [oci_core_security_list.extra_subnet_security_list[0].id]
1515
freeform_tags = var.freeform_deployment_tags
16+
17+
count = var.create_new_subnet ? 1 : 0
1618
}
1719

1820
resource "oci_core_route_table" "extra_subnet_route_table" {
@@ -25,6 +27,8 @@ resource "oci_core_route_table" "extra_subnet_route_table" {
2527
description = "Traffic to/from internet"
2628
destination = lookup(var.network_cidrs, "ALL-CIDR")
2729
destination_type = "CIDR_BLOCK"
28-
network_entity_id = oci_core_internet_gateway.oke_internet_gateway[0].id
30+
network_entity_id = var.oke_vcn_internet_gateway_ocid
2931
}
32+
33+
count = var.create_new_subnet ? 1 : 0
3034
}

modules/new-subnet-from-oke-vcn/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33
#
44

5+
variable "create_new_subnet" {
6+
default = false
7+
description = "Create a new node pool if true or use an existing one if false"
8+
}
9+
510
variable "network_cidrs" {
611
type = map(string)
712

@@ -35,7 +40,14 @@ variable "subnet_name" {
3540
description = "Subnet Name"
3641
}
3742

43+
# Deployment Details + Freeform Tags
44+
variable "freeform_deployment_tags" {
45+
description = "Tags to be added to the resources"
46+
}
47+
3848
# Subnet Name Locals
3949
locals {
50+
app_name_for_dns = substr(lower(replace(local.app_name,"/\\W|_|\\s/","")), 0, 6)
4051
subnet_name_normalized = substr(replace(lower(var.subnet_name), " ", "-"), 0, 6)
52+
deploy_id = var.freeform_deployment_tags.DeploymentID
4153
}

0 commit comments

Comments
 (0)