Move Data from One Firestore Project to Another - Permission Denied
ยท 2 min read
This cost me so much time, export data and importing it into another firestore project.
Making this because I lost so much time myself on this.
I wanted to export a collection and import it into another Firestore database in another project.
I followed all these guides:
I also checked these discussions:
- Stack Overflow: gcloud firestore import permission denied
- Google Cloud Community: Firestore Backup and Restore
Some of these articles alluded to my fix but weren't completely clear. Here's what I did:
๐ ๏ธ Steps to Move Dataโ
- Ownership: I was the owner of both projects which might be nescessary.
- Export Collection: Export the collection to a new storage bucket in the source project. (Note: This might not be necessary; you might be able to export directly to the existing Firestore if you prefer.)
- Add Permissions to Service Account:
- Find the service account with a long number by going to the destination project bucket, then permissions.
- This account will not show up under the destination project's IAM.
- Look for the service account in this format:
service-[LONG_FKN_NUMBER]@gcp-sa-firestore.iam.gserviceaccount.com
. - Allow this service account access to the source bucket.
gsutil iam ch serviceAccount:service-[LONG_FKN_NUMBER]@gcp-sa-firestore.iam.gserviceaccount.com:legacyBucketReader,legacyObjectReader \
gs://[SOURCE_BUCKET]
- Import Data: Once the permissions are set correctly, the import should work.
๐ Laaaterโ
By following these steps, you should be able to move your Firestore data between projects without encountering permission issues.
Happy coding!