Skip to content

Commit 439a1e3

Browse files
authored
Merge pull request #94 from lantier/feature/node-pools-oauth-scopes
Add feature to define individual oauth scopes to node pools
2 parents ab5ec5d + f3647e4 commit 439a1e3

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ module "gke" {
4444
},
4545
]
4646
47+
node_pools_oauth_scopes = {
48+
all = []
49+
50+
default-node-pool = [
51+
"https://www.googleapis.com/auth/cloud-platform",
52+
]
53+
}
54+
4755
node_pools_labels = {
4856
all = {}
4957

cluster_regional.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ resource "google_container_node_pool" "pools" {
132132
service_account = "${lookup(var.node_pools[count.index], "service_account", local.service_account)}"
133133
preemptible = "${lookup(var.node_pools[count.index], "preemptible", false)}"
134134

135-
oauth_scopes = [
136-
"https://www.googleapis.com/auth/cloud-platform",
137-
]
135+
oauth_scopes = ["${concat(var.node_pools_oauth_scopes["all"], var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}"]
138136
}
139137

140138
lifecycle {

cluster_zonal.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ resource "google_container_node_pool" "zonal_pools" {
132132
service_account = "${lookup(var.node_pools[count.index], "service_account", local.service_account)}"
133133
preemptible = "${lookup(var.node_pools[count.index], "preemptible", false)}"
134134

135-
oauth_scopes = [
136-
"https://www.googleapis.com/auth/cloud-platform",
137-
]
135+
oauth_scopes = ["${concat(var.node_pools_oauth_scopes["all"], var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}"]
138136
}
139137

140138
lifecycle {

examples/node_pool/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ module "gke" {
6363
},
6464
]
6565

66+
node_pools_oauth_scopes = {
67+
all = []
68+
69+
pool-01 = []
70+
71+
pool-02 = []
72+
}
73+
6674
node_pools_metadata = {
6775
all = {}
6876

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ variable "node_pools_tags" {
180180
}
181181
}
182182

183+
variable "node_pools_oauth_scopes" {
184+
type = "map"
185+
description = "Map of lists containing node oauth scopes by node-pool name"
186+
187+
default = {
188+
all = ["https://www.googleapis.com/auth/cloud-platform"]
189+
default-node-pool = []
190+
}
191+
}
192+
183193
variable "stub_domains" {
184194
type = "map"
185195
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

0 commit comments

Comments
 (0)