Giter VIP home page Giter VIP logo

Comments (10)

evamaxfield avatar evamaxfield commented on June 12, 2024

Seems like we can use the Firebase CLI to do this. So either a post-script thing or writing our own ComponentResource to do subprocess it out to the CLI

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

This is now possible with the Pulumi 3.0 Google Native Provider:

https://www.pulumi.com/docs/reference/pkg/google-native/firebaserules/v1/ruleset/

I attempted it but it is finicky and tricky to get right / I may have been doing something incorrectly. Going to hold off until needed for research queries.

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

Firestore public read rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read: if request.auth == null;
    }
  }
}

Firebase storage public read rules:

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read;
    }
  }
}

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

Looks like the process for this will be:

  1. create the rulesets with: https://www.pulumi.com/docs/reference/pkg/google-native/firebaserules/v1/ruleset/
  2. use the rulesets in https://www.pulumi.com/docs/reference/pkg/google-native/firebaserules/v1/release/

It seems they may have updated the docs but it seems a bit more doable considering we can dump the text contents to a File object.

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

Got it working! 🎉

I ditched trying to get Pulumi ruleset working and went with a simple node script

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

Alright. I thought I had it working but when doing thorough testing, I saw that was failing to initialize the Firestore Security Rules.

Everything runs through just fine, all resources are technically created but Firestore Security Rules aren't being applied. They will only apply after visiting the Firestore Security Rules Web UI and then rerunning the set-public-read script. In some cases, I get an "entity does not exist" error.

I opened a ticket with Firebase Support so hopefully I will hear back soon.

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

Was attempting to pull transcript files from bucket but ran into permissions error, apparently true public read isn't set on the bucket unless you have a bucket iam policy set:

# Set full public read on bucket
self.storage_public_read = storage.BucketIamPolicy(
    f"{self.gcp_project_id}-storage-public-read",
    bucket=self.firestore_app.default_bucket,
    bindings=[
        storage.BucketIamPolicyBindingsItemArgs(
            role="roles/storage.objectViewer",
            members=["allUsers"],
        ),
    ],
    opts=pulumi.ResourceOptions(parent=self.firestore_app),
)

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

Tracking with Firebase support and pulumi/pulumi-google-native#196

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

Also needs a CORS rule: https://firebase.google.com/docs/storage/web/download-files#download_data_via_url

from cdp-backend.

evamaxfield avatar evamaxfield commented on June 12, 2024

Parts of this (specifically the CORS) may be able to be completed with a Dynamic Provider: https://www.pulumi.com/blog/dynamic-providers/

from cdp-backend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.