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

Document how to create a firebaserules_release for non-default Firestore databases. #16324

Closed

Comments

@IchordeDionysos
Copy link

IchordeDionysos commented Oct 20, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

There is no functional change needed for this feature to work, it just needs to be documented.

I had to go through the source code of firebase-tools to figure out how it works:

There the databaseId is passed as an optional third parameter.
https://github.com/firebase/firebase-tools/blob/master/src/deploy/firestore/release.ts#L30
Which will then be appended to the resource name as a sub resource name.
https://github.com/firebase/firebase-tools/blob/master/src/rulesDeploy.ts#L257
This will then be the release name:
https://github.com/firebase/firebase-tools/blob/master/src/gcp/rules.ts#L267
https://github.com/firebase/firebase-tools/blob/master/src/gcp/rules.ts#L253

New or Affected Resource(s)

  • google_firebaserules_release

Potential Terraform Configuration

The following is a working example:

resource "google_firestore_database" "secondary" {
  project     = google_project.project.project_id
  name        = "secondary"
  location_id = "nam5"
  type        = "FIRESTORE_NATIVE"
}

resource "google_firebaserules_release" "secondary" {
  name         = "cloud.firestore/${google_firestore_database.secondary.name}"
  ruleset_name = "projects/my-project-name/rulesets/${google_firebaserules_ruleset.firestore.name}"
  project      = "my-project-name"

  lifecycle {
    replace_triggered_by = [
      google_firebaserules_ruleset.firestore
    ]
  }
}

resource "google_firebaserules_ruleset" "firestore" {
  source {
    files {
      content = "service cloud.firestore {match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } }"
      name    = "firestore.rules"
    }
  }

  project = "my-project-name"
}

References

b/307505398

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.