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 service_account to google_cloudbuild_trigger #3661

Conversation

modular-magician
Copy link
Collaborator

Fix hashicorp/terraform-provider-google#10053.

Add service_account to google_cloudbuild_trigger (Included in the REST documentation).

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

cloudbuild: added field `service_account` to `google_cloudbuild_trigger`

Derived from GoogleCloudPlatform/magic-modules#5237

@modular-magician modular-magician merged commit d889103 into hashicorp:master Sep 24, 2021
@maniimanjari
Copy link

terraform {
required_providers {
google = {
version = "~> 3.0.0-beta.1"
}
}
}
provider "google" {
project = var.project_id
region = var.location
}
resource "google_service_account" "service_account" {
account_id = "cloudrun"
display_name = "Service Account to deploy apps to cloudrun"
project = var.project_id
}
locals{
rolesList = toset (["roles/run.developer","roles/storage.objectAdmin", "roles/cloudoptimization.serviceAgent", "roles/iam.serviceAccountUser", "roles/artifactregistry.writer" ])
}

resource "google_project_iam_binding" "cloud_build_sa" {
for_each = local.rolesList
project = var.project_id
role = each.key
members = [
"serviceAccount:${google_service_account.service_account.email}"
]
}
resource "google_cloudbuild_trigger" "Trigger" {
provider = google
github {
owner = var.Repo_Org
name = var.Repo_Name
push {
branch = var.branch_env
}
}
name = "${var.Repo_Name}-${var.branch_env}"
description = "Deploy Trigger for ${var.Repo_Name} to cloud-run"
filename = "cloudbuild.yaml"
service_account = "projects/${var.project_id}/serviceAccounts/${google_service_account.service_account.email}"
}

This throws errors listed below
Error: Insufficient trigger_template blocks

│ on main.tf line 38, in resource "google_cloudbuild_trigger" "Trigger":
│ 38: resource "google_cloudbuild_trigger" "Trigger" {

│ At least 1 "trigger_template" blocks are required.


│ Error: Unsupported block type

│ on main.tf line 40, in resource "google_cloudbuild_trigger" "Trigger":
│ 40: github {

│ Blocks of type "github" are not expected here.


│ Error: Unsupported argument

│ on main.tf line 52, in resource "google_cloudbuild_trigger" "Trigger":
│ 52: service_account = "****"

│ An argument named "service_account" is not expected here.

Can you please correct me here ? I need to use github but not trigger_template

@modular-magician modular-magician deleted the downstream-pr-9019f4cd74d3fff788a3837beb2a4abe37df4c4c branch November 16, 2024 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google_cloudbuild_trigger support for service account
2 participants