This file documents how to configure Google Cloud Storage to use on your machine.
To work on this project this isn't mandatory: it's possible to use a mocked version of the service as described below.
Copy the file .env.example to .env, then edit it in your favorite editor
following the embedded comments.
If you're using the Mozilla project, the bucket name you can use is
profile-store-julien-dev. Otherwise please use the one you create following
the section below.
Create a file in your project directory, called .env. Here is the
content it should have:
GCS_AUTHENTICATION_PATH="MOCKED"
JWT_SECRET="<something you choose>"
If you're a Mozilla employee, you can jump directly to the last paragraph in this section.
Otherwise you can start following the steps starting at the first paragraph.
Here we'll create a new project in the Google Cloud Platform ecosystem.
- Connect to your cloud console. Take care that you use the Google account you want from the top right menu.
- Click
Select a projectat the top, then chooseNew Projectat the top right of the modal.
In this part we'll create a socalled bucket to hold our uploaded data.
- Select the option
Storage > Storagein the menu at the left. Note: you can pin this option so that you can always find it at the top of this menu. You can also bookmark this direct link. - To enable this API you'll need to sign up for a free trial, including configuring your billing and payment options. You'll have the option to access it from this page if it's not done yet. As said above configuring GCS isn't necessary to contribute to this project.
Then we'll create a role to make it easier to configure permissions, and update them in the future.
- Access the Role configuration through IAM > Roles.
- Click on
Create roleat the top of the page. - You can name this role
profile publisherand change the description if you wish. You can also change the ID name toprofile.publisher, and the Role launch stage toGeneral Availability. - Then you can add some permissions. To search for the permissions, you can
enter terms in the Filter table input, not the Filter permissions by role
input.
You can search for
storage.objects, and select the following permissions:storage.objects.create: allows to create objectsstorage.objects.delete: allows to overwrite existing objectsstorage.buckets.get: allows to check if the bucket exists
- Finally click on
Createat the bottom.
In this part we'll create a service account with the profile publisher role that can access the API. We prefer to have a different account for each developer rather than share the account.
You can follow these steps:
- Connect to IAM > Service accounts part in your console.
- Make sure the right project is selected at the top. If you have several Google accounts, you might need to change your Google account at the top right as well.
- Click on the button
Create service accountnear the top of the page. - Chose a descriptive name, like
profiler-server-<name>-dev. You can add a description as well. - Don't create any new role yet, we'll assign some more later.
- Click on
Create key, and download it as JSON. Store it on your local disk. - Keep the full email for this account in your clipboard, as we'll need it later.
In this paragraph we'll create a new bucket and assign permissions to the previously created service account.
- Now you can create a bucket from the Storage
browser. According to the
Google princing page, if you
choose the regions
us-west1,us-central1, orus-east1it should be free if you stay below some threshold. Otherwise keep the other options at their default values. - Now from the same browser you can select the newly created bucket by clicking its checkbox. At the right panel you can click Add member.
- Copy the full service account email in the field, then press Enter. (Don't use the autocomplete box as sometimes it doesn't work properly.)
- In the Role part, look for
profile publisherand add it. - Finally save the form.
If you're a Mozilla employee, you can instead request access to the project
moz-fx-dev-jwajsberg-profiler, part of the Mozilla GCP instance.
Then you can create a service account and assign the right permissions for this new account to the existing bucket in the project as outlined above. Note that this bucket will be emptied from time to time.