Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Firebase, Firestore and BigQuery on the Production Environment #4955

Closed
7 tasks done
adhiamboperes opened this issue Apr 21, 2023 · 1 comment
Closed
7 tasks done
Assignees
Labels
enhancement End user-perceivable enhancements. Impact: High High perceived user impact (breaks a critical feature or blocks a release). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet.

Comments

@adhiamboperes
Copy link
Collaborator

adhiamboperes commented Apr 21, 2023

Set Up Requirements

  • Upgrading the project plan to Blaze. This is necessary to be able to stream data to BigQuery in realtime, and to install the extension that supports this.

Set Up Cloud Firestore

Enable Firestore for the Project

  • Owner role, or Editor role with Firebase Role: Develop Admin.
  • Navigate to the Cloud Firestore section of the Firebase console.
  • You'll be prompted to create a database. Follow the database creation workflow.
    • Under secure rules for Cloud Firestore, select Start in production mode. This prevents external reads and writes.
    • For Set Cloud Firestore location, select region as US, which is the same as the existing Firebase configuration for analytics and crashlytics.
    • Click enable.

Add Security Rules

  • Once in the Cloud Firestore Console, navigate to the Rules tab.
  • Change the rules to:
rules_version = '2';
// Scopes the rules to the firestore product
service cloud.firestore {
  // Specifies that rules should match any Cloud Firestore database
 match /databases/{database}/documents {
   // Specifies that the rule applies to any document in the nps_survey_open_feedback collection
   // As a result, they also deny access to documents in all other collections, which would have to be granted explicitly.
  match /nps_survey_open_feedback/{document} {
    allow read, write: if request.auth != null;
  	}
    }
}
  • Click publish.

Stream Collections to BigQuery Integration

  • In the Cloud Firestore Console, navigate to the Extensions tab.
  • Click Install on the Stream Collections to BigQuery extension.
  • The project billing has already been set, so click on Next.
  • Review APIs enabled and resources created and enable Cloud Functions and Artifact Registry which are required for this extension to function properly.
  • Review access granted to this extension. No action is required.
  • Configure extension
    - Cloud Functions location, which is the same as the Cloud Firestore location above
    - BigQuery Dataset location: United States(multi-regional)
    - Project Id: oppia-android. In production this will correspond to the prod project id.
    - Collection path: nps_survey_open_feedback. This is the name our collection will have on Firestore.
    - Dataset ID: nps_survey_open_feedback_export
    - Table ID: nps_survey_open_feedback. This is what our collection will be called once exported to BigQuery. We need this since we haven't actually created the collection in Firestore, but the extension will create it in BigQuery.
    - We don't need to configure any of the optionals.
    - Click to Install Extension

Extension Documentation: Stream Collections to BigQuery

Note - in production, we will also configure our data retention time to live per our retention policy. Ref #4904

Firebase Anonymous Authentication

Enable Anonymous Auth

In the Firebase console, Open the Build/Authentication menu.

  • On the Sign-in Methods page, enable the Anonymous sign-in method.
@BenHenning
Copy link
Member

These should all be configured now for production. @adhiamboperes and I made the configuration changes in a work session today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement End user-perceivable enhancements. Impact: High High perceived user impact (breaks a critical feature or blocks a release). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet.
Development

No branches or pull requests

3 participants