4.1 KiB
Read this on the main serverless docs site
Google - Credentials
The Serverless Framework needs access to account credentials for your Google Cloud account so that it can create and manage resources on your behalf.
Create a Google Cloud Billing Account
You need a Billing Account with a credit card attached to use Google Cloud Functions. Here's how to create one:
- Click here, to go to the screen to create a new Billing Account.
- Enter the name of the Billing Account and enter your billing information. Then click Submit to enable billing.
- A Billing Account will exist already offering you a free trial. Please note that this will not work for Google Cloud Functions. Only a Billing Account with a valid credit card will work.
If necessary, a more detailed guide on creating a Billing Account can be found here.
Create a new Google Cloud Project
A Google Cloud Project is required to use Google Cloud Functions. Here's how to create one:
- Go to the Google Cloud Console.
- There is a dropdown near the top left of the screen (near the search bar that lists your projects). Click it and select "Create Project".
- Enter a Project name and select the Billing Account you created in the steps above (or any Billing Account with a valid credit card attached).
- Click on "Create" to start the creation process.
- Wait until the Project was successfully created and Google will redirect you to your new Project.
- Verify your currently within your new Project by looking at the dropdown next to the search bar. This should mark your new Project as selected.
Enable the necessary APIs
You need to enable the following APIs so that Serverless can create the corresponding resources.
Go to the API dashboard, select your project and enable the following APIs (if not already enabled):
- Google Cloud Functions
- Google Cloud Deployment Manager
- Google Cloud Storage
- Stackdriver Logging
Get credentials & assign roles
You need to create credentials with appropriate roles Serverless can use to create resources in your Project.
- Go to the Google Cloud Console.
- Choose the project that you are working on from the top drop down
- Click
IAM & adminmenu on left-sidebar - Then click
Service accountson left-sidebar - Click
CREATE SERVICE ACCOUNTbutton on the top - Input Service account name and Service account ID will be generated automatically for you. Change it if you wish to.
- Click
Createbutton - Add
Deployment Manager Editor,Storage Admin,Logging Admin,Cloud Functions Developerroles and clickContinue - Click
+CREATE KEYbutton and selectJSONkey type and clickCreatebutton - You will see a json (AKA
keyfile) file downloaded - Click
Donebutton - Save the
keyfilesomewhere secure. We recommend making a folder in your root folder and putting it there. Like this,~/.gcloud/keyfile.json. You can change the file name fromkeyfileto anything. Remember the path you saved it to.
Update the provider config in serverless.yml
Open up your serverless.yml file and update the provider section with your Google Cloud Project id and
the path to your keyfile.json file (this path needs to be absolute!). It should look something like this:
provider:
name: google
runtime: nodejs
project: my-serverless-project-1234
credentials: ~/.gcloud/keyfile.json