Automates IAM role, API enablement, and optionally bucket permissions for Firebase Functions deployment.
-
gcloud CLI installed and authenticated
gcloud auth login
-
gsutil (comes with gcloud)
-
Owner or IAM Admin access to the target GCP project (and bucket project if different)
./scripts/setup-project-permissions.sh <PROJECT_ID> [DEPLOY_SERVICE_ACCOUNT_EMAIL] [BUCKET_PROJECT] [BUCKET_NAME]Setup deployment project only (recommended for initial setup):
./scripts/setup-project-permissions.sh dietbet-stagingSetup with custom deploy service account:
./scripts/setup-project-permissions.sh fitnessai-api firebase-function-deploy@my-other-project.iam.gserviceaccount.comSetup deployment project AND grant bucket permissions:
./scripts/setup-project-permissions.sh dietbet-staging firebase-function-deploy@appex-data-imports.iam.gserviceaccount.com appex-data-imports appex_app_payloadsSetup production project with bucket permissions:
./scripts/setup-project-permissions.sh dietbet-5771b firebase-function-deploy@appex-data-imports.iam.gserviceaccount.com appex-data-imports appex_app_payloadsStage 1: Deployment Project Permissions
- Grants IAM Roles:
Firebase Admin— Required to deploy Firebase FunctionsService Account User— Required on default compute SA to impersonate itService Usage Consumer— Allows Firebase CLI to enable APIs automatically
- Enables APIs:
- Cloud Functions API
- Cloud Build API
- Artifact Registry API
- Cloud Run Admin API
- Eventarc API
Stage 2: Bucket Permissions (Optional)
- Grants
Storage Object Adminon the specified bucket to the compute SA - Includes warnings/confirmations before making changes
- Falls back to manual instructions if gsutil fails
- The script uses
firebase-function-deploy@appex-data-imports.iam.gserviceaccount.comby default - If using a different deploy service account, pass it as the second argument
- API enablement may take 1-2 minutes to propagate
- Bucket permissions are optional — only provide if deploying immediately
When to use bucket parameters:
- After the deployment project is fully set up
- When you're ready to grant bucket access
- ONLY if you're certain about the bucket identity
When NOT to use:
- First time setup — just configure the deployment project first
- If you're unsure which bucket to use — run without bucket parameters and verify manually first
- If the bucket is in the same project — you can still use this, but it's optional
Manual bucket setup alternative: If the script fails or you prefer manual setup:
- Go to: https://console.cloud.google.com/storage/browser/`<BUCKET_NAME>
?project=<BUCKET_PROJECT>` - Permissions → Grant Access
- Add principal:
<PROJECT_NUMBER>-compute@developer.gserviceaccount.com - Role:
Storage Object Admin - Save
If your bucket is in a different project, ensure Storage API is enabled:
https://console.cloud.google.com/apis/library/storage.googleapis.com?project=<BUCKET_PROJECT_ID>