Skip to content

Commit

Permalink
Add cloud build viewer IAM member.
Browse files Browse the repository at this point in the history
  • Loading branch information
xingao267 committed Apr 21, 2020
1 parent 690cc0f commit ddefb52
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Terraform/cicd/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,18 @@ resource "google_project_service" "devops_apis" {
disable_on_destroy = false
}

# Cloud Build - IAM permissions
# IAM permissions to allow approvers and contributors to view the build results.
resource "google_project_iam_member" "cloudbuild_viewers" {
for_each = toset(var.build_viewers)
project = var.devops_project_id
role = "roles/cloudbuild.builds.viewer"
member = each.value
depends_on = [
google_project_service.devops_apis,
]
}

# Cloud Build - Cloud Build Service Account IAM permissions
# IAM permissions to allow Cloud Build SA to access state.
resource "google_storage_bucket_iam_member" "cloudbuild_state_iam" {
bucket = var.state_bucket
Expand Down
3 changes: 3 additions & 0 deletions Terraform/cicd/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ branch_regex = "terraform"
continuous_deployment_enabled = true
trigger_enabled = true
terraform_root = "Terraform"
build_viewers = [
"group:rocketturtle-gcp-admin@rocketturtle.net",
]
6 changes: 6 additions & 0 deletions Terraform/cicd/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ variable "terraform_root" {
description = "Path of the directory relative to the repo root containing the Terraform configs"
default = "."
}

variable "build_viewers" {
type = list(string)
description = "List of IAM members to grant cloudbuild.builds.viewer role in the devops project to see CICD results"
default = []
}

0 comments on commit ddefb52

Please sign in to comment.