-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
311 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,73 @@ | ||
variable "gke_name" { | ||
type = string | ||
description = "Name of the GKE cluster" | ||
validation { | ||
condition = length(var.gke_name) > 0 | ||
error_message = "gke_name must not be an empty string" | ||
} | ||
} | ||
|
||
variable "gke_name" {} | ||
variable "main_region" {} | ||
variable "gke_node_count" {} | ||
variable "project_id" {} | ||
variable "env_name" {} | ||
variable "network" {} | ||
variable "subnetwork" {} | ||
variable "main_region" { | ||
description = "Region for the subnetwork" | ||
type = string | ||
validation { | ||
condition = length(var.main_region) > 0 | ||
error_message = "Region cannot be empty!" | ||
} | ||
|
||
validation { | ||
condition = contains([ | ||
"us-east1", "us-east4", "us-west1", "us-west2", "us-west3", "us-west4", "us-central1", | ||
"northamerica-northeast1", "southamerica-east1", "europe-west1", "europe-west2", "europe-west3", | ||
"europe-west4", "europe-west6", "asia-east1", "asia-east2", "asia-northeast1", "asia-northeast2", | ||
"asia-northeast3", "asia-southeast1", "asia-southeast2", "australia-southeast1" | ||
], var.main_region) | ||
error_message = "Use an approved region!" | ||
} | ||
} | ||
|
||
|
||
variable "gke_node_count" { | ||
type = number | ||
description = "Number of nodes in the GKE cluster" | ||
validation { | ||
condition = var.gke_node_count > 0 | ||
error_message = "gke_node_count must be greater than 0" | ||
} | ||
} | ||
|
||
variable "project_id" { | ||
type = string | ||
description = "Google Cloud project ID" | ||
validation { | ||
condition = length(var.project_id) > 0 | ||
error_message = "project_id must not be an empty string" | ||
} | ||
} | ||
|
||
variable "env_name" { | ||
type = string | ||
description = "Environment name" | ||
validation { | ||
condition = length(var.env_name) > 0 | ||
error_message = "env_name must not be an empty string" | ||
} | ||
} | ||
|
||
variable "network" { | ||
type = string | ||
description = "Name of the network" | ||
validation { | ||
condition = length(var.network) > 0 | ||
error_message = "network must not be an empty string" | ||
} | ||
} | ||
|
||
variable "subnetwork" { | ||
type = string | ||
description = "Name of the subnetwork" | ||
validation { | ||
condition = length(var.subnetwork) > 0 | ||
error_message = "subnetwork must not be an empty string" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,75 @@ | ||
variable "cluster_id" {} | ||
variable "cluster_id" { | ||
validation { | ||
condition = var.cluster_id != "" | ||
error_message = "Cluster ID cannot be an empty string." | ||
} | ||
} | ||
|
||
variable "region" { | ||
description = "Region for the subnetwork" | ||
type = string | ||
validation { | ||
condition = length(var.region) > 0 | ||
error_message = "Region cannot be empty!" | ||
} | ||
|
||
validation { | ||
condition = contains([ | ||
"us-east1", "us-east4", "us-west1", "us-west2", "us-west3", "us-west4", "us-central1", | ||
"northamerica-northeast1", "southamerica-east1", "europe-west1", "europe-west2", "europe-west3", | ||
"europe-west4", "europe-west6", "asia-east1", "asia-east2", "asia-northeast1", "asia-northeast2", | ||
"asia-northeast3", "asia-southeast1", "asia-southeast2", "australia-southeast1" | ||
], var.region) | ||
error_message = "Use an approved region!" | ||
} | ||
} | ||
|
||
variable "region" {} | ||
variable "name" {} | ||
|
||
variable "name" { | ||
description = "Node pool name" | ||
type = string | ||
validation { | ||
condition = length(var.name) > 0 | ||
error_message = "Node pool name cannot be empty!" | ||
} | ||
} | ||
|
||
variable "default_node_count" { | ||
default = 1 | ||
default = 1 | ||
validation { | ||
condition = var.default_node_count > 0 | ||
error_message = "Default node count must be greater than 0." | ||
} | ||
} | ||
|
||
variable "max_nodes" { | ||
validation { | ||
condition = var.max_nodes > 0 | ||
error_message = "Max nodes must be greater than 0." | ||
} | ||
} | ||
|
||
variable "min_nodes" { | ||
validation { | ||
condition = var.min_nodes > 0 | ||
error_message = "Min nodes must be greater than 0." | ||
} | ||
} | ||
check "default_min_max_nodes_check" { | ||
assert { | ||
condition = var.min_nodes > 0 && var.min_nodes < var.max_nodes | ||
error_message = "Min nodes must be greater than 0 and less than max nodes." | ||
} | ||
assert { | ||
condition = var.default_node_count >= var.min_nodes && var.default_node_count <= var.max_nodes | ||
error_message = "Default node count must be between min nodes and max nodes." | ||
} | ||
} | ||
|
||
variable "node_locations" { | ||
default = ["us-central1-b"] | ||
# validation { | ||
# condition = can(all(regex("^[a-zA-Z][0-9]+-[a-z]$", var.node_locations))) | ||
# error_message = "Invalid format for node locations. Each location should be in the format 'region-availability_zone' (e.g., 'us-central1-b')." | ||
# } | ||
} | ||
variable "max_nodes" {} | ||
variable "min_nodes" {} | ||
variable "node_locations" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.