Installing this extension is made to be as simple as possible. However, due to Firebase Extensions limitations, there are some post installation steps you must undertake. Below is a step-by-step guide from start to finish in how to get this extension up and running. I have also included brief clips showcasing what each step looks like for those that are more visual!
1
Install from Firebase Extensions Hub
Installing from Firebase Extensions Hub
In Firebase Extension Hub, navigate to the Auto Stop Services extension and click the install button.
2
Upgrade to Blaze Plan
Upgrading to Blaze Plan
In the Extension Installation menu, upgrade to Blaze Plan (if your project isn't already on this plan). Otherwise continue to the next step.
3
Configure the Extension
Configuring the extension
Following the steps outlined in the Extension Installation menu, configure the extension as appropriate for your project.
The default settings will work fine too!
A full detail of each parameter can be found in the section on this page.
4
Verify the Installation
Verifying the installation
Once the extension is installed, verify that there are no error messages and that two functions were created.
In some rare instances the installation may fail. You will see a red dialog appear - just select "retry installation" and you should be good to go!
5
Setup a Budget
Setting up a Budget
You must create a Budget against your project and Billing Account if none exists. When you first upgrade to Blaze plan, you will typically have set this up.
You can setup a budget via Firebase Console (recommended) or GCP.
Firebase: Go to Settings > Usage & Billing. Set a budget and note its name.
GCP: Navigate to Billing > Budgets. Create a new budget, set it, and note the budget name.
6
Connect the Budget to the Pub/Sub topic
Connecting the Budget to the Pub/Sub topic
This extension installed a Pub/Sub topic with the name you configured during installation. This was the {TOPIC_NAME} parameter, which by default is "ext-firebase-trigger-auto-stop".
Navigate to your Budget and select "Connect a pub/sub topic to this budget" and choose the pub/sub topic relating to this extension. Note that in this view you may have to select your project (by clicking "switch project" in the dropdown) for the topic to appear.
7
Update the Service Account permissions
Updating the Service Account permissions
Finally, you must navigate to IAM and grant IAM roles to the extension's Service Account. The roles will depend on which strategy you have selected.
Grant the following IAM roles to {EXTENSION_NAME}@{PROJECT_ID}.iam.gserviceaccount.com:
Strategy 1: Grant Project Billing Manager (roles/billing.projectManager) to manage project billing settings.
Strategy 2: Service Usage Admin (roles/serviceusage.serviceUsageAdmin) for enabling/disabling service APIs.
8
You are good to go!
Feel free to test the extension and ensure it is working correctly. See below.
Configurable Parameters
During the extension installation, you will be asked to configure it with the following parameters:
Parameter
Definition
Default Value
TOPIC_NAME
The name of the pub/sub topic. A billing alert is published here, which will trigger the auto-stop (if the threshold is reached).
ext-firebase-trigger-auto-stop
BUDGET_STOP_THRESHOLD_PERCENT
The percentage (0.0-1.0) of the budget that will trigger the stop strategy, default is 1.0 (100%)
1.0
DISABLE_BILLING
Enables strategy 1 - to remove the billing account (requires project billing manager role)
Yes (true)
DISABLE_API_LIST
Enables strategy 2 - to disable services (requires service usage admin role).
[Empty]
LOCATION
Defines the deployment location for the cloud function.
us-central1
Example Pub/Sub Message
When a budget alert fires, the message content will look like the below:
The key element of this message is the alertThresholdExceeded, all other information is effectively discarded.
Testing this Extension
Once you have followed the steps, you can submit a message through the pub/sub topic. Any results will be published as logs, which you can monitor.
This example message will not execute any strategy.
{
"extensionTest": true
}
Example Log
Below is the log output when sending the test message. Note that this specific example is for Strategy 1 only which requires the Project Billing Manager role, while the Service Usage Admin role is not required.