Skip to content

Commit

Permalink
Fix review comment: Change ports magic to explicit udpFirewall
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerlynn committed Jan 24, 2023
1 parent 63bd753 commit b50e320
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion build/terraform/e2e/gke-autopilot/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module "gke_cluster" {
"location" = "us-west1"
}

ports = "" // firewall is created at the project module level
udpFirewall = false // firewall is created at the project module level
}

provider "helm" {
Expand Down
2 changes: 1 addition & 1 deletion build/terraform/e2e/gke-standard/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module "gke_cluster" {
"project" = var.project
}

ports = "" // firewall is created at the project module level
udpFirewall = false // firewall is created at the project module level
}

provider "helm" {
Expand Down
2 changes: 1 addition & 1 deletion install/terraform/modules/gke-autopilot/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ resource "google_container_cluster" "primary" {
}

resource "google_compute_firewall" "default" {
count = var.ports != "" ? 1 : 0
count = var.udpFirewall ? 1 : 0
name = length(var.firewallName) == 0 ? "game-server-firewall-${local.name}" : var.firewallName
project = local.project
network = local.network
Expand Down
40 changes: 23 additions & 17 deletions install/terraform/modules/gke-autopilot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Ports can be overriden using tfvars file. If ports is empty, no firewall is declared.
variable "ports" {
default = "7000-8000"
}

# SourceRanges can be overriden using tfvars file
variable "sourceRanges" {
default = "0.0.0.0/0"
}

# Set of GKE cluster parameters which defines its name, zone
# and primary node pool configuration.
# It is crucial to set valid ProjectID for "project".
Expand All @@ -30,16 +20,32 @@ variable "cluster" {
type = map(any)

default = {
"name" = "test-cluster"
"project" = "agones"
"location" = "us-west1"
"network" = "default"
"subnetwork" = ""
"releaseChannel" = "REGULAR"
"kubernetesVersion" = "1.24"
"name" = "test-cluster"
"project" = "agones"
"location" = "us-west1"
"network" = "default"
"subnetwork" = ""
"releaseChannel" = "REGULAR"
"kubernetesVersion" = "1.24"
}
}

# udpFirewall specifies whether to create a UDP firewall named
# `firewallName` with port range `ports`, source range `sourceRanges`
variable "udpFirewall" {
default = true
}

# Ports can be overriden using tfvars file
variable "ports" {
default = "7000-8000"
}

# SourceRanges can be overriden using tfvars file
variable "sourceRanges" {
default = "0.0.0.0/0"
}

variable "firewallName" {
description = "name for the cluster firewall. Defaults to 'game-server-firewall-{local.name}' if not set."
type = string
Expand Down
2 changes: 1 addition & 1 deletion install/terraform/modules/gke/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ resource "google_container_cluster" "primary" {
}

resource "google_compute_firewall" "default" {
count = var.ports != "" ? 1 : 0
count = var.udpFirewall ? 1 : 0
name = length(var.firewallName) == 0 ? "game-server-firewall-${local.name}" : var.firewallName
project = local.project
network = local.network
Expand Down
36 changes: 21 additions & 15 deletions install/terraform/modules/gke/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Ports can be overriden using tfvars file
variable "ports" {
default = "7000-8000"
}

# SourceRanges can be overriden using tfvars file
variable "sourceRanges" {
default = "0.0.0.0/0"
}

# Set of GKE cluster parameters which defines its name, zone
# and primary node pool configuration.
# It is crucial to set valid ProjectID for "project".
variable "cluster" {
description = "Set of GKE cluster parameters."
type = map
type = map(any)

default = {
"location" = "us-west1-c"
"location" = "us-west1-c"
"name" = "test-cluster"
"machineType" = "e2-standard-4"
"initialNodeCount" = "4"
Expand All @@ -40,12 +30,28 @@ variable "cluster" {
"kubernetesVersion" = "1.24"
"windowsInitialNodeCount" = "0"
"windowsMachineType" = "e2-standard-4"
"autoscale" = false
"minNodeCount" = "1"
"maxNodeCount" = "5"
"autoscale" = false
"minNodeCount" = "1"
"maxNodeCount" = "5"
}
}

# udpFirewall specifies whether to create a UDP firewall named
# `firewallName` with port range `ports`, source range `sourceRanges`
variable "udpFirewall" {
default = true
}

# Ports can be overriden using tfvars file
variable "ports" {
default = "7000-8000"
}

# SourceRanges can be overriden using tfvars file
variable "sourceRanges" {
default = "0.0.0.0/0"
}

variable "firewallName" {
description = "name for the cluster firewall. Defaults to 'game-server-firewall-{local.name}' if not set."
type = string
Expand Down

0 comments on commit b50e320

Please sign in to comment.