Skip to content

Commit 31cb015

Browse files
Add storage.objectViewer role to SA
* Added `grant_registry_access` variable to grant `roles/storage.objectViewer` to created SA (Fixes #229)
1 parent 98b6e7f commit 31cb015

File tree

15 files changed

+77
-0
lines changed

15 files changed

+77
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Extending the adopted spec, each change should have a link to its corresponding
99
## [Unreleased]
1010
### Added
1111

12+
* Added `grant_registry_access` variable to grant `roles/storage.objectViewer` to created SA [#236]
13+
1214
* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
1315
* Support for Workload Identity beta feature [#234]
1416

@@ -168,6 +170,7 @@ Extending the adopted spec, each change should have a link to its corresponding
168170
[v0.3.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.2.0...v0.3.0
169171
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0
170172

173+
[#236]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/236
171174
[#216]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/216
172175
[#214]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/214
173176
[#210]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/210

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
137137
| create\_service\_account | Defines if service account specified to run nodes should be created. | bool | `"true"` | no |
138138
| description | The description of the cluster | string | `""` | no |
139139
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | bool | `"true"` | no |
140+
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
140141
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
141142
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |
142143
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | number | `"0"` | no |

autogen/sa.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
6161
role = "roles/monitoring.viewer"
6262
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
6363
}
64+
65+
resource "google_project_iam_member" "cluster_service_account-gcr" {
66+
count = var.create_service_account && var.grant_registry_access ? 1 : 0
67+
project = var.project_id
68+
role = "roles/storage.objectViewer"
69+
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
70+
}
71+

autogen/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ variable "create_service_account" {
261261
default = true
262262
}
263263

264+
variable "grant_registry_access" {
265+
type = bool
266+
description = "Grants created cluster-specific service account storage.objectViewer role."
267+
default = false
268+
}
269+
264270
variable "service_account" {
265271
type = string
266272
description = "The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created."

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
153153
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | bool | `"false"` | no |
154154
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | bool | `"false"` | no |
155155
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool | `"false"` | no |
156+
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
156157
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
157158
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |
158159
| identity\_namespace | Workload Identity namespace | string | `""` | no |

modules/beta-private-cluster/sa.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
6161
role = "roles/monitoring.viewer"
6262
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
6363
}
64+
65+
resource "google_project_iam_member" "cluster_service_account-gcr" {
66+
count = var.create_service_account && var.grant_registry_access ? 1 : 0
67+
project = var.project_id
68+
role = "roles/storage.objectViewer"
69+
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
70+
}
71+

modules/beta-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ variable "create_service_account" {
261261
default = true
262262
}
263263

264+
variable "grant_registry_access" {
265+
type = bool
266+
description = "Grants created cluster-specific service account storage.objectViewer role."
267+
default = false
268+
}
269+
264270
variable "service_account" {
265271
type = string
266272
description = "The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created."

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
145145
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
146146
| enable\_intranode\_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | bool | `"false"` | no |
147147
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool | `"false"` | no |
148+
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
148149
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
149150
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |
150151
| identity\_namespace | Workload Identity namespace | string | `""` | no |

modules/beta-public-cluster/sa.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
6161
role = "roles/monitoring.viewer"
6262
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
6363
}
64+
65+
resource "google_project_iam_member" "cluster_service_account-gcr" {
66+
count = var.create_service_account && var.grant_registry_access ? 1 : 0
67+
project = var.project_id
68+
role = "roles/storage.objectViewer"
69+
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
70+
}
71+

modules/beta-public-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ variable "create_service_account" {
261261
default = true
262262
}
263263

264+
variable "grant_registry_access" {
265+
type = bool
266+
description = "Grants created cluster-specific service account storage.objectViewer role."
267+
default = false
268+
}
269+
264270
variable "service_account" {
265271
type = string
266272
description = "The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created."

0 commit comments

Comments
 (0)