Skip to content

docs(taskqueues): spell out the IAM bindings and add the Python README - #1341

Merged
jhuleatt merged 4 commits into
mainfrom
docs/taskqueues-iam-and-python-readme
Oct 7, 2026
Merged

jhuleatt merged 4 commits into
mainfrom
docs/taskqueues-iam-and-python-readme

Conversation

@jhuleatt

@jhuleatt jhuleatt commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

One step in the IAM section of Node/taskqueues-backup-images/README.md said only "follow Google Cloud IAM documentation to add App Engine default service account as user of App Engine default service account". #1088 points out that this doesn't say which role to grant or how. The step now names the role (roles/iam.serviceAccountUser) and gives the gcloud command. A short paragraph explains the 401/403 errors that #1088, #1105, and #1143 ran into when a binding is missing.

The section also names the right identity. The sample uses requiresRole(), and with it the Firebase CLI creates a service account for the codebase (firebase-fn-…@<project-id>.iam.gserviceaccount.com), grants it the declared roles, and runs every function as that account (firebase-tools discoverSecurityDetails). The old text said the Compute Engine default service account, which would have sent you to bind the wrong account. The gcloud commands now use a ${FUNCTIONS_SA} placeholder for that email, and a sentence says when the Compute Engine default applies instead (if you remove requiresRole).

Python/taskqueues-backup-images/README.md was a one-line stub. It now describes the two functions, setup, deployment, and the same IAM bindings. The Python SDK has no equivalent of requiresRole(), so those functions run as the Compute Engine default service account and the README says to grant the roles with gcloud.

Fixes #1088
Related: #1105, #1143

Verification

Docs only. The gcloud commands follow the pattern already used in the Node.js README. Not deployed; the managed service account behavior comes from the firebase-tools source linked above.

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

Copy link
Copy Markdown
Contributor

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 Node.js task queue backup images README with clearer IAM instructions and troubleshooting tips, and adds a comprehensive README for the Python version of the sample. The review feedback suggests updating the IAM policy command in the Python README to use gcloud run services add-iam-policy-binding instead of gcloud functions add-iam-policy-binding for 2nd gen Cloud Functions.

Comment on lines +81 to +84
gcloud functions add-iam-policy-binding backupapod \
--region=us-east4 \
--member=serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com \
--role=roles/run.invoker

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For 2nd gen Cloud Functions, the underlying service is a Cloud Run service. The recommended and standard way to grant the invoker role is using gcloud run services add-iam-policy-binding instead of gcloud functions add-iam-policy-binding.

Suggested change
gcloud functions add-iam-policy-binding backupapod \
--region=us-east4 \
--member=serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com \
--role=roles/run.invoker
gcloud run services add-iam-policy-binding backupapod \
--region=us-east4 \
--member=serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com \
--role=roles/run.invoker

@jhuleatt

jhuleatt commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Changed the --region in the new Python README to us-central1, which is where the sample deploys. See #1347 for why the us-east4 strings are going away.

The Python sample sets no region, so it deploys to us-central1. #1347
puts the other sample URLs back to us-central1 as well.
The Node.js sample passes no uri when it enqueues tasks; the Admin SDK
resolves the URL from the queue name. Name the binding requiresRole
doesn't grant, say how to target a function in another region (#1002),
and mention the Python SDK version that rejected Cloud Tasks tokens
(firebase-functions-python#157).
With requiresRole, the Firebase CLI creates a service account for the
codebase and runs every function as it, so the by-hand
roles/iam.serviceAccountUser binding must target that account, not the
Compute Engine default.
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.

[DOCS] for sample: taskqueues-backup-images, not clear how to set up "impersonation" permission

1 participant