README
# firebase-billing-limiter
Automatically disable billing for firebase projects that surpass a certain amount
Install
Run npm i firebase-billing-limiter
or yarn add firebase-billing-limiter
Configuration
Billing Member Role
Access your GCP console, in the Billing tab it's necessary to go to "Account Management". Make sure that the selected billing account is the billing used on the Firebase project you want to use this package.
Next, it's necessary to give a member role to your cloud function's service account. The next image shows the location of the service account.
Billing API
You also need to enable the GCP's Cloud Billing API
Project Quotas
Finally, it's necessary to set some billing usage quotas, The billing will only be disabled, if the value you set for a quota it's the same as provided on the disableProjectAmount
property. Also, it's necessary to create a topic on this budget. Make sure the quota is assigned to the desired project only. The Topic ID will later be passed as a property topicId
.
In the image's case, I can assign 5, 9 or 10
to the disableProjectAmount property.
Usage
On the index.[ts|js]
add the following cloud function:
import BillingLimiter from "firebase-billing-limiter";
exports.BillingLimiter = BillingLimiter({
disableProjectAmount: 10.0, // The amount that will trigger the disabling (in your project billing currency).
topicId: "billing", // The topicid created on the quotas.
});