Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cloud build viewer IAM member. #201

Merged
merged 2 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = []
}
2 changes: 2 additions & 0 deletions Terraform/engine.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ templates:
CONTINUOUS_DEPLOYMENT_ENABLED: true
TRIGGER_ENABLED: true
TERRAFORM_ROOT: "Terraform"
BUILD_VIEWERS:
- "group:rocketturtle-gcp-admin@rocketturtle.net"

# Folder
- name: "folder-heroes-hat"
Expand Down