| name | gcp-firebase-infrastructure |
| description | Manage Google Cloud Platform and Firebase infrastructure with Terraform. Use when: (1) Setting up Firebase projects, (2) Configuring GCP resources, (3) Managing multi-environment infrastructure (dev/staging/prod), (4) Deploying Firestore/Storage rules, (5) Configuring IAM permissions, (6) Managing secrets, or working with Terraform for GCP/Firebase. Keywords: firebase, gcp, terraform, firestore, cloud functions, infrastructure, environment, deployment, security rules. Use when this capability is needed. |
GCP/Firebase Infrastructure Management
Manage Firebase and Google Cloud Platform infrastructure using Terraform and Firebase CLI, with support for multi-environment deployments.
When to Use This Skill
- Setting up or modifying Firebase projects
- Creating or updating GCP resources (Cloud Functions, Firestore, Storage)
- Managing infrastructure across dev/staging/prod environments
- Deploying security rules for Firestore or Cloud Storage
- Configuring IAM permissions and secrets management
- Working with Terraform modules for GCP/Firebase
Prerequisites
Tools: Firebase CLI, Google Cloud CLI, Terraform
Authentication:
firebase login
gcloud auth login
gcloud auth application-default login
Multi-Environment Pattern
| Environment | Purpose | Resources |
|---|
| dev | Local development | Firebase Emulator Suite |
| staging | Pre-production testing | Separate Firebase/GCP project |
| prod | Production | Production Firebase/GCP project |
Environment Structure:
Core Workflows
Firebase Operations
firebase use <project-id>
firebase init
firebase deploy --only firestore:rules
firebase deploy --only functions
firebase deploy
firebase emulators:start
Terraform Operations
cd terraform/environments/staging
terraform init
terraform plan
terraform apply
Secrets Management
GitHub: Settings → Secrets → Add (reference as ${{ secrets.NAME }})
GCP:
echo -n "value" | gcloud secrets create NAME --data-file=-``
✅ **DO:**
- Use separate Firebase projects for each environment
- Test in staging before deploying to production
- Use `terraform plan` before `terraform apply`
- Store secrets in Secret Manager (not environment files)
- Apply least-privilege IAM permissions
- Version control Terraform state with remote backend
- Document environment-specific variables
- Use Firestore indexes for complex queries
❌ **DON'T:**
- Commit `.tfstate` files or secret values to git
- Hardcode environment-specific values in code
- Grant overly broad IAM permissions
- Deploy to production without staging verification
- Modify production infrastructure without review
- Skip `terraform plan` before applying changes
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Firebase CLI not authenticated | Run `firebase login` |
| Terraform state locked | `terraform force-unlock <lock-id>` |
| Permission denied on deploy | Check IAM roles for service account |
| Security rules rejected | Test with emulator first: `firebase emulators:start` |
| Function deployment fails | Check logs: `firebase functions:log` |
| Secret not accessible | Verify Secret Manager IAM bindings |
## Quick Reference
**Firebase CLI:**
```bash
firebase projects:list # List projects
firebase use <project-id> # Switch project
firebase deploy --only <service> # Deploy specific service
firebase functions:log # View function logs
firebase emulators:start # Start local emulators
Terraform:
terraform init
terraform plan
terraform apply
terraform destroy
terraform state list
gcloud:
gcloud projects list
gcloud config set project <project-id>
gcloud secrets list
gcloud iam service-accounts list
Detailed References
Context7 Resources
- Firebase Admin:
@context7 /firebase/firebase-admin-node
- Google Cloud:
@context7 /googleapis/google-cloud-node
- Terraform GCP:
@context7 /hashicorp/terraform-provider-google
Separate projects per environment, test in staging first, use terraform plan
❌ Don't commit .tfstate or secrets, grant minimal IAM permissions```bash
Firebase
firebase use
firebase deploy --only
firebase functions:log
Terraform
terraform plan
terraform apply
terraform state list
gcloud
gcloud config set project
gcloud secrets list
Converted and distributed by TomeVault — claim your Tome and manage your conversions.