jenkins-x / terraform-google-jx

A Terraform module for creating Jenkins X infrastructure on Google Cloud
Apache License 2.0
38 stars 96 forks source link

fix: define oauth scopes for the autoscaled nodepool #189

Closed paukul closed 3 years ago

paukul commented 3 years ago

This fixes oauth scopes not being set for the autoscaled pool that got introduced in #106

Background: the auto scaled pool has different oauth scopes (the default ones) than the clusters default pool. Default pool: image Auto scaled pool: image Presumably this also causes the issue described in #169

Fix: The same oauth permissions are applied both to the clusters default pool and the autoscale pool using the auto_provisioning_defaults in the cluster_autoscaling block: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#oauth_scopes This consistently restores oauth scopes across both pools to the state pre #106

Note: The long term solution to this, according to googles and terraforms documentation, would be setting a non-default service account with fine grained permission on IAM level

google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. This is not part of this PR because I'm not aware of what permissions are required

Safety: This change is save to re-apply with terraform although it won't change the existing pools configuration. In order for these changes to take effect, recreating the autoscale pool (or, of course, the cluster) is required. However, terraform doesn't fail if a cluster has been created pre this change and then another apply with the updated terraform configuration is run.