Search code examples
terraformgcloudterraform-provider-gcp

Can we able to change GCP cloud build settings using terraform or gcloud command


I have a use-case where I need to enable cloud build access on GKE but I did not found a terraform resource to do that, also not found gcloud CLI command to do the same. enter image description here


Solution

  • Yes, you can do this in Terraform by creating a google_project_iam_member for the Cloud Build service account that's created by default when you enable the Cloud Build API. For example:

    resource "google_project_iam_member" "cloudbuild_kubernetes_policy" {
      project = var.project_id 
      role = "roles/container.developer"
      member = "serviceAccount:${var.project_number}@cloudbuild.gserviceaccount.com"
    }
    

    The value declared in the role attribute/key corresponds to a role in the console user interface (an image of which you have included above).