Skip to content

Commit

Permalink
Removed shared_vpc variables
Browse files Browse the repository at this point in the history
  • Loading branch information
dunefro committed Dec 2, 2024
1 parent 8871e08 commit c9cdc53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 46 deletions.
6 changes: 3 additions & 3 deletions gcn.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# # Create a VPC network

module "network" {
count = var.shim || var.shared_vpc ? 0 : 1
count = var.use_existing_network ? 0 : 1
source = "terraform-google-modules/network/google"
version = "9.3.0"
description = "Truefoundry network for ${var.cluster_name}"
Expand Down Expand Up @@ -76,13 +76,13 @@ module "network" {
}

resource "time_sleep" "wait_2_mins" {
count = var.shim || var.shared_vpc ? 0 : 1
count = var.use_existing_network ? 0 : 1
depends_on = [module.network[0]]

create_duration = "2m"
}
module "cloud_router" {
count = var.shim || var.shared_vpc ? 0 : 1
count = var.use_existing_network ? 0 : 1
source = "terraform-google-modules/cloud-router/google"
version = "6.2.0"
description = "Truefoundry NAT router for ${var.cluster_name}"
Expand Down
14 changes: 2 additions & 12 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
output "network_name" {
value = var.shim || var.shared_vpc ? var.shared_vpc ? var.shared_vpc_network_name : var.network_name : module.network[0].network_name
description = "Name of the network"
}

output "network_id" {
value = var.shim || var.shared_vpc ? var.shared_vpc ? "projects/${var.shared_vpc_host_project}/global/networks/${var.shared_vpc_network_name}" : "projects/${var.project_id}/global/networks/${var.network_name}" : module.network[0].network_id
value = var.use_existing_network ? var.network_id : module.network[0].network_id
description = "ID of the network"
}

output "subnet_id" {
value = var.shim || var.shared_vpc ? var.shared_vpc ? "projects/${var.shared_vpc_host_project}/regions/${var.region}/subnetworks/${var.shared_vpc_subnet_name}" : var.subnet_id : module.network[0].subnets_ids[0]
value = var.use_existing_network ? var.subnet_id : module.network[0].subnets_ids[0]
description = "ID of the subnet"
}

output "additional_secondary_ranges" {
value = var.shim || var.shared_vpc ? var.shared_vpc ? [] : [] : module.network[0].subnets_secondary_ranges
description = "Additional secondary ranges applied to the subnet"
}
36 changes: 5 additions & 31 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,28 @@ variable "cluster_name" {
################################################################################
# Network
################################################################################
variable "shim" {
description = "If true will not create the network and forward the input values to the same outputs."
type = bool
default = false
}

variable "shared_vpc" {
description = "If true, the shim network is a shared VPC"
variable "use_existing_network" {
description = "If true will not create the network and forward the input values to the same outputs."
type = bool
default = false
}

################################################################################
# Network SHIM
################################################################################
variable "network_name" {
description = "SHIM: network name. Should be supplied if shim is true."
variable "network_id" {
description = "ID of the existing network. Only used when use_existing_network is set to true"
type = string
default = ""
}

variable "subnet_id" {
description = "SHIM: Subnetwork ID. Should be supplied if shim is true."
description = "ID of the existing subnet. Only used when use_existing_network is set to true"
type = string
default = ""
}

################################################################################
# Shared VPC
################################################################################

variable "shared_vpc_host_project" {
description = "Shared VPC: Project ID of the host project. Should be supplied if shared_vpc is true."
type = string
default = ""
}

variable "shared_vpc_network_name" {
description = "Shared VPC: Network name. Should be supplied if shared_vpc is true."
type = string
default = ""
}

variable "shared_vpc_subnet_name" {
description = "Shared VPC: Subnet name. Should be supplied if shared_vpc is true."
type = string
default = ""
}
################################################################################
# Network NON-SHIM
################################################################################
Expand Down

0 comments on commit c9cdc53

Please sign in to comment.