Skip to main content

Move Data from One Firestore Project to Another - Permission Denied

ยท 2 min read
Jason Hollifield
Founder @ Hollplex

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:

Some of these articles alluded to my fix but weren't completely clear. Here's what I did:

๐Ÿ› ๏ธ Steps to Move Dataโ€‹

  1. Ownership: I was the owner of both projects which might be nescessary.
  2. 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.)
  3. 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]
  1. 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!