Skip to content

Enforce dedicated service account for Cloud Build triggers#110

Merged
haroonc merged 8 commits intomainfrom
service_account
Apr 9, 2026
Merged

Enforce dedicated service account for Cloud Build triggers#110
haroonc merged 8 commits intomainfrom
service_account

Conversation

@alex-doudou
Copy link
Copy Markdown
Contributor

@alex-doudou alex-doudou commented Mar 26, 2026

  • Tests pass
  • Appropriate changes to documentation are included in the PR

This PR:

  • updated how_to_create_cloudbuild_trigger.md to include a mandatory step for creating/using a dedicated service account.
  • explicitly assigned required roles (logging, artifactregistry, developerconnect) to the dedicated SA.
  • mandated passing the dedicated SA email to the create_build_trigger tool.
  • updated roles to grant for the dedicated Cloud Run service account and developer connect service agent

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the security posture for Cloud Build triggers by mandating the use of dedicated service accounts. It ensures that triggers operate with the principle of least privilege, thereby reducing potential security risks. The changes primarily involve updating documentation to guide users through the process of setting up and assigning appropriate roles to these dedicated service accounts, and explicitly requiring their use when creating new triggers.

Highlights

  • Mandatory Dedicated Service Accounts: Enforced the use of dedicated, user-managed service accounts for Cloud Build triggers to adhere to the principle of least privilege, replacing the default Compute Engine service account.
  • Required IAM Roles: Explicitly defined the minimum necessary IAM roles (roles/logging.logWriter, roles/artifactregistry.writer, roles/developerconnect.tokenAccessor) that must be granted to the dedicated service account.
  • Tool Parameter Update: Mandated that the email of the dedicated service account must be provided to the service_account parameter when using the create_build_trigger tool.
  • Documentation Update: Updated the how_to_create_cloudbuild_trigger.md guide to include detailed steps for checking, creating, and configuring the dedicated service account.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the how_to_create_cloudbuild_trigger.md documentation to include a new section on ensuring a dedicated service account is used for Cloud Build triggers, detailing the creation process and required roles, and emphasizes providing this service account to the create_build_trigger tool. Feedback indicates a critical discrepancy where the create_build_trigger tool does not enforce the use of a dedicated service account, potentially leading to security issues, and suggests modifying the tool to require this parameter. Additionally, a minor markdown formatting issue was noted in a new heading.

@alex-doudou
Copy link
Copy Markdown
Contributor Author

Added the follow up commit to enforce the service account behaviour in our go tool as well.

The commit:

  • Modified create_build_trigger to require the service_account parameter.
  • Removed silent fallback to the default Compute Engine service account.
  • Updated unit tests to verify the mandatory behavior and removed obsolete fallback tests.

@haroonc haroonc force-pushed the service_account branch 2 times, most recently from ab401d5 to da645fe Compare March 28, 2026 04:52
yeshwanth1993
yeshwanth1993 previously approved these changes Apr 8, 2026
@haroonc
Copy link
Copy Markdown
Contributor

haroonc commented Apr 9, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request mandates the use of a dedicated service account for Cloud Build triggers, removing the previous fallback to the default Compute Engine service account. It expands the setPermissionsForCloudBuildSA function to automate IAM role assignments for the Cloud Build service account and associated service agents. Documentation is updated to reflect these changes. Feedback points to a potential lack of idempotency in IAM bindings, missing test coverage for resource manager errors, and minor documentation inaccuracies.

@haroonc haroonc merged commit 057fe7b into main Apr 9, 2026
4 checks passed
@alex-doudou alex-doudou deleted the service_account branch April 9, 2026 17:26
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.

3 participants