Skip to content

Commit b3996e2

Browse files
authored
fix: add browser role to cloud build sa for provided folders (terraform-google-modules#484)
1 parent 3172201 commit b3996e2

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

4-projects/modules/infra_pipelines/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
| cloudbuild\_plan\_filename | Path and name of Cloud Build YAML definition used for terraform plan. | `string` | `"cloudbuild-tf-plan.yaml"` | no |
1111
| cloudbuild\_project\_id | The project id where the pipelines and repos should be created | `string` | n/a | yes |
1212
| default\_region | Default region to create resources where applicable. | `string` | n/a | yes |
13+
| folders\_to\_grant\_browser\_role | List of folders to grant browser role to the cloud build service account. Used by terraform validator to able to load IAM policies. | `list(string)` | `[]` | no |
1314
| gar\_repo\_name | Custom name to use for GAR repo. | `string` | `""` | no |
1415
| impersonate\_service\_account | Service account email of the account to impersonate to run Terraform | `string` | n/a | yes |
1516
| project\_prefix | Name prefix to use for projects created. | `string` | `"prj"` | no |

4-projects/modules/infra_pipelines/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,11 @@ resource "google_artifact_registry_repository_iam_member" "terraform-image-iam"
180180
role = "roles/artifactregistry.writer"
181181
member = "serviceAccount:${data.google_project.cloudbuild_project.number}@cloudbuild.gserviceaccount.com"
182182
}
183+
184+
resource "google_folder_iam_member" "browser_cloud_build" {
185+
for_each = toset(var.folders_to_grant_browser_role)
186+
187+
folder = each.value
188+
role = "roles/browser"
189+
member = "serviceAccount:${data.google_project.cloudbuild_project.number}@cloudbuild.gserviceaccount.com"
190+
}

4-projects/modules/infra_pipelines/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,9 @@ variable "terraform_validator_release" {
9595
type = string
9696
default = "2021-03-22"
9797
}
98+
99+
variable "folders_to_grant_browser_role" {
100+
description = "List of folders to grant browser role to the cloud build service account. Used by terraform validator to able to load IAM policies."
101+
type = list(string)
102+
default = []
103+
}

0 commit comments

Comments
 (0)