Skip to content

Commit

Permalink
feat: updated attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Apr 18, 2024
1 parent 8a30e36 commit b620f39
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
10 changes: 5 additions & 5 deletions example/managed-node-pools/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ module "gke" {
cluster_autoscaling = false
http_load_balancing = false
horizontal_pod_autoscaling = false
master_authorized_networks_config {
cidr_blocks {
cidr_block = "10.10.128.0/24"
display_name = "internal"
master_authorized_networks = [
{
cidr_block = "10.0.0.7/32"
display_name = "net1"
}
}
]
managed_node_pool = [
{
name = "critical"
Expand Down
2 changes: 1 addition & 1 deletion example/managed-node-pools/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ variable "label_order" {

variable "gcp_project_id" {
type = string
default = "cloud-crew-testing"
default = "clouddrove"
description = "Google Cloud project ID"
}

Expand Down
10 changes: 5 additions & 5 deletions example/self-hosted-node-pools/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ module "gke" {
cluster_autoscaling = false
http_load_balancing = false
horizontal_pod_autoscaling = false
master_authorized_networks_config {
cidr_blocks {
cidr_block = "10.10.128.0/24"
display_name = "internal"
master_authorized_networks = [
{
cidr_block = "10.0.0.7/32"
display_name = "net1"
}
}
]
self_node_pools = [
{
name = "critical"
Expand Down
2 changes: 1 addition & 1 deletion example/self-hosted-node-pools/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ variable "label_order" {

variable "gcp_project_id" {
type = string
default = "cloud-crew-testing"
default = "clouddrove"
description = "Google Cloud project ID"
}

Expand Down
13 changes: 5 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "google_container_cluster" "primary" {
min_master_version = var.gke_version
deletion_protection = var.deletion_protection
cluster_ipv4_cidr = var.cluster_ipv4_cidr
initial_node_count = var.initial_node_count
initial_node_count = var.managed_node_pool == {} ? var.initial_node_count : 0

cluster_autoscaling {
enabled = var.cluster_autoscaling
Expand Down Expand Up @@ -47,14 +47,11 @@ resource "google_container_cluster" "primary" {
}
}
dynamic "master_authorized_networks_config" {
for_each = { for k, v in var.master_authorized_networks_config : k => v if var.enabled }
for_each = var.master_authorized_networks
content {
dynamic "cidr_blocks" {
for_each = master_authorized_networks_config.value.cidr_blocks
content {
cidr_block = cidr_blocks.value
display_name = cidr_blocks.value
}
cidr_blocks {
cidr_block = master_authorized_networks_config.value["cidr_block"]
display_name = master_authorized_networks_config.value["display_name"]
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ variable "node_count" {
description = "The number of nodes to create in this cluster's default node pool."
}

variable "master_authorized_networks_config" {
type = list(object({ cidr_block = string, display_name = string }))
description = "List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
default = []
variable "master_authorized_networks" {
type = list(object({
cidr_block = string
display_name = string
}))
description = "List of master authorized networks"
}

variable "managed_node_pool" {
Expand Down

0 comments on commit b620f39

Please sign in to comment.