Skip to content

How to generate credentials in GCP?

To access GCP, you generate credentials using Service accounts on IAM console.

The credentials in GCP include ONE single file in JSON format that contains all the neccessary information for authentication.

Project and billing

The services in Google Cloud are organized in projects, each project has its own ID, billing account and permissions to use the GCP resources through service accounts.

INFO

Each project used to deploy resources has to have a billing account with a credit card attached.

  1. First go to the "Create a project" console after logging in

GCP Leftside menu

  1. Choose a project name and a unique project ID (to use it on CloudStudio)

GCP New Project

  1. Go to "Billing" on the new created project

GCP New billing account

  1. Go to "Manage billing accounts" to create a new account

GCP Manage billing account

  1. Click on "Create account"

GCP Create billing account

  1. Choose a name and a country for the new account and click on "Continue"

GCP New billing account name

  1. Add or choose a credit card and click on "Submit and enable billing"

GCP New billing account credit card

  1. Create a budget alert on the new billing account and go back to "billing"

GCP Billing account budget alert

  1. On the tab of "My projects" select the "Change billing" action on the new project

GCP Projects tabs

  1. Select the new account and click on "Set account"

GCP Project attached to new account

Service account keys

The service accounts are used for external applications (like CloudStudio) to access resources on a GCP account, controling its access through roles and permissions.

INFO

Every service account belongs to an specific project within GCP, so every resource created though a service account will live on that specfic project. To use a service account, the external app will connect to it by a JSON file created in the IAM console and downloaded on local machine.

  1. First go to the "Security accounts" on the new project dashboard

GCP Leftside menu

  1. In the new opened console click "Create Service Account"

GCP Service accounts

  1. Give it a name and appropriate description

GCP Create service account 1

  1. Grant "Owner" role to access most GCP resources within that project

GCP Create service account 2

  1. Skip the "Grant users access" step and confirm operation

GCP Create service account 3

  1. Back to the Service accounts list, select the recently created and click "Manage Keys"

GCP Service account manage keys

  1. Click on the selector "Add Key" and then on the "Create New Key" option

GCP Service account add key

  1. Choose JSON format and click on "Create" to download the credentials file

GCP Service account download key

APIs and Project permissions

Before start working with the new credentials, the APIs of each service to be deployed have to be enabled on the project.

INFO

The APIs for each Google service of a project can be enable or disable on the library.

  1. Go to "library" in the APIs and services section

GCP Leftside menu

  1. Search for the service you want to deploy on Google cloud

GCP Library

  1. Select the service you are looking for

GCP Library search

  1. Click on "enable" and wait until it takes effect

GCP Service API enable

INFO

Additionally if you want to use the credentials generated on "Project A" to deploy resources on "Project B" you'll need to add the same service account with owner role to "Project B".

  1. Go to "IAM" console on the "Project B" you want to link to the credentials of "Project A"

GCP Leftside menu

  1. Click on "Grant access"

GCP IAM console

  1. Select the name of the service account of "Project A" and give it an owner role, save it

GCP IAM grant access

Add secrets to CloudStudio

INFO

After downloading the credentials JSON file, its content should look like this

GCP credentials example

  1. Go to the Google provider on the CloudStudio dashboard and click "add secret"

CloudStudio add keys 1

  1. Copy the root to the JSON file, paste it on the app_credentials value and apply changes

CloudStudio add keys 2

  1. Finally set created secret to the current app environment

CloudStudio add keys 3

Released under a Personal use License.