Skip to content

Commit

Permalink
Add storage.objectViewer role to SA
Browse files Browse the repository at this point in the history
 * Added `sa_grant_gcs_access` variable to grant `roles/storage.objectViewer` to created SA (Fixes #229)
  • Loading branch information
paulpalamarchuk committed Aug 16, 2019
1 parent 98b6e7f commit d893d5c
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Extending the adopted spec, each change should have a link to its corresponding
## [Unreleased]
### Added

* Added `sa_grant_gcs_access` variable to grant `roles/storage.objectViewer` to created SA [#236]

* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
* Support for Workload Identity beta feature [#234]

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

[#236]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/236
[#216]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/216
[#214]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/214
[#210]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/210
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
| sa\_grant\_gcs\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
| service\_account | 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. | string | `""` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map(list(string)) | `<map>` | no |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
Expand Down
8 changes: 8 additions & 0 deletions autogen/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
role = "roles/monitoring.viewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
count = var.create_service_account && var.sa_grant_gcs_access ? 1 : 0
project = var.project_id
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

6 changes: 6 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ variable "create_service_account" {
default = true
}

variable "sa_grant_gcs_access" {
type = bool
description = "Grants created cluster-specific service account storage.objectViewer role."
default = false
}

variable "service_account" {
type = string
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."
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
| sa\_grant\_gcs\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
| service\_account | 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. | string | `""` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map(list(string)) | `<map>` | no |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
Expand Down
8 changes: 8 additions & 0 deletions modules/beta-private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
role = "roles/monitoring.viewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
count = var.create_service_account && var.sa_grant_gcs_access ? 1 : 0
project = var.project_id
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

6 changes: 6 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ variable "create_service_account" {
default = true
}

variable "sa_grant_gcs_access" {
type = bool
description = "Grants created cluster-specific service account storage.objectViewer role."
default = false
}

variable "service_account" {
type = string
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."
Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
| sa\_grant\_gcs\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
| service\_account | 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. | string | `""` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map(list(string)) | `<map>` | no |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
Expand Down
8 changes: 8 additions & 0 deletions modules/beta-public-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
role = "roles/monitoring.viewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
count = var.create_service_account && var.sa_grant_gcs_access ? 1 : 0
project = var.project_id
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

6 changes: 6 additions & 0 deletions modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ variable "create_service_account" {
default = true
}

variable "sa_grant_gcs_access" {
type = bool
description = "Grants created cluster-specific service account storage.objectViewer role."
default = false
}

variable "service_account" {
type = string
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."
Expand Down
1 change: 1 addition & 0 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
| sa\_grant\_gcs\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
| service\_account | 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. | string | `""` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map(list(string)) | `<map>` | no |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
Expand Down
8 changes: 8 additions & 0 deletions modules/private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
role = "roles/monitoring.viewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
count = var.create_service_account && var.sa_grant_gcs_access ? 1 : 0
project = var.project_id
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

6 changes: 6 additions & 0 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ variable "create_service_account" {
default = true
}

variable "sa_grant_gcs_access" {
type = bool
description = "Grants created cluster-specific service account storage.objectViewer role."
default = false
}

variable "service_account" {
type = string
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."
Expand Down
8 changes: 8 additions & 0 deletions sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
role = "roles/monitoring.viewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
count = var.create_service_account && var.sa_grant_gcs_access ? 1 : 0
project = var.project_id
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ variable "create_service_account" {
default = true
}

variable "sa_grant_gcs_access" {
type = bool
description = "Grants created cluster-specific service account storage.objectViewer role."
default = false
}

variable "service_account" {
type = string
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."
Expand Down

0 comments on commit d893d5c

Please sign in to comment.