tolerate missing IAM permissions when provisioning default compute SA#10806
Open
leoortizz wants to merge 3 commits into
Open
tolerate missing IAM permissions when provisioning default compute SA#10806leoortizz wants to merge 3 commits into
leoortizz wants to merge 3 commits into
Conversation
App Hosting deploy provisions the default compute service account on every run, creating it and granting it IAM roles. The catch blocks only ignored 409 (create) and 400 (roles), so a least-privilege deploy identity that lacks iam.serviceAccounts.create or resourcemanager.projects.setIamPolicy got a 403 that was rethrown, hard-failing the deploy even when the service account already existed and worked. Treat 403 in both catch blocks as a warning-and-continue so deploys from restricted identities are no longer blocked. Fixes #8840
Contributor
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where App Hosting deployments failed if the deploying account lacked permissions to create or grant roles to the default compute service account. Instead of throwing an error and failing the deployment, the code now catches 403 (Permission Denied) errors during these steps, logs a warning, and continues. Unit tests have been added to verify this behavior, and the CHANGELOG.md has been updated accordingly. There are no review comments, so I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #8840.
App Hosting deploys attempt to provision the default compute service account (
firebase-app-hosting-compute) on every run — creating it and granting it IAM roles. The error handling only tolerated409 Already Existson creation and400on the role grant. A least-privilege deploy identity (e.g. a CI service account authenticated viaGOOGLE_APPLICATION_CREDENTIALSor Workload Identity Federation) that lacksiam.serviceAccounts.createorresourcemanager.projects.setIamPolicyinstead receives a403, which was rethrown and hard-failed the entire deploy — even though the service account already existed and was fully functional.This change treats a
403from either call as a warning-and-continue, so deploys from restricted identities are no longer blocked. When the service account already exists (the common case for these users), the warnings are informational and the deploy proceeds normally.Scenarios Tested
iam.serviceAccounts.createandresourcemanager.projects.setIamPolicy, against a project where the compute service account already exists:Permission 'iam.serviceAccounts.create' denied on resource.403(setIamPolicy) when creation permission is present but role-granting permission is not.403paths (create and role grant); fullbackend.spec.tssuite passes.Sample Commands
deploy