Ir al contenido

Google Cloud Credentials

Esta página aún no está disponible en tu idioma.

A Cloud Run deploy authenticates as a Google Cloud service account, using a JSON key you create once and paste into the Designer. This page is the exact procedure: which APIs to turn on, which roles to grant, how to create the key, and how to confirm it works before running a deploy.

ThingExampleWhere it goes
Project IDacme-prod-1234GCP project id
Cloud Run regionasia-southeast1Cloud Run region
Artifact Registry repositorygreenticArtifact Registry repository (optional — defaults to greentic)
Service-account keya JSON fileService-account key JSON
Runtime service accountgtc-acme-runtime@acme-prod-1234.iam.gserviceaccount.comCreated for you on the first deploy — see Runtime service account

The project ID, not the project name or number. In the Google Cloud console the ID is the lowercase, hyphenated string shown under Project ID on the project picker — it often has a numeric suffix Google appended.

The deploy and its preflight both call Google APIs directly. Each must be enabled on the project or every request returns 403 SERVICE_DISABLED.

Terminal window
gcloud services enable \
cloudresourcemanager.googleapis.com \
artifactregistry.googleapis.com \
iam.googleapis.com \
run.googleapis.com \
secretmanager.googleapis.com \
--project=acme-prod-1234
APIUsed by
cloudresourcemanager.googleapis.comthe permission check, at project scope
artifactregistry.googleapis.compushing the bundle image, and the repository-scope permission check
iam.googleapis.comthe actAs check on the runtime service account
run.googleapis.comcreating and updating the Cloud Run service
secretmanager.googleapis.comstoring the deployment’s secrets
  1. Open IAM & Admin → Service Accounts in the Google Cloud console, with the right project selected, and click Create service account.

  2. Name it something that says what it is — greentic-deployer is a good default. Note the generated address; you need it in the next step. It looks like greentic-deployer@acme-prod-1234.iam.gserviceaccount.com.

  3. Skip the “Grant this service account access” step. The roles are granted explicitly below, some of them at a scope this screen cannot express.

Or, in one command:

Terminal window
gcloud iam service-accounts create greentic-deployer \
--display-name="Greentic deployer" \
--project=acme-prod-1234

Greentic checks permissions at three different scopes, because Google answers a permission question only for the resource you ask about. A grant made at the wrong scope is invisible to the deploy even though it is plainly there in the console.

Set these once:

Terminal window
PROJECT=acme-prod-1234
REGION=asia-southeast1
REPO=greentic
SA=greentic-deployer@$PROJECT.iam.gserviceaccount.com
Terminal window
gcloud projects add-iam-policy-binding $PROJECT \
--member="serviceAccount:$SA" --role=roles/run.admin --condition=None
gcloud projects add-iam-policy-binding $PROJECT \
--member="serviceAccount:$SA" --role=roles/secretmanager.admin --condition=None
gcloud projects add-iam-policy-binding $PROJECT \
--member="serviceAccount:$SA" --role=roles/logging.viewer --condition=None
gcloud projects add-iam-policy-binding $PROJECT \
--member="serviceAccount:$SA" --role=roles/iam.serviceAccountAdmin --condition=None
  • roles/logging.viewer lets the Designer’s Log tab read your deployed service’s logs with this same key. roles/run.admin does not include it.
  • roles/iam.serviceAccountAdmin lets Greentic create the runtime service account for you on the first deploy (next section). Without it, the first deploy stops and hands you two gcloud commands to run by hand instead.

The bundle image is pushed from Greentic, so this account needs write, not just read.

If the repository already exists, grant on the repository — narrower, and it is where Greentic looks:

Terminal window
gcloud artifacts repositories add-iam-policy-binding $REPO \
--location=$REGION --project=$PROJECT \
--member="serviceAccount:$SA" --role=roles/artifactregistry.writer

If it does not exist yet, grant at project scope instead, and add artifactregistry.admin so the first deploy can create it:

Terminal window
gcloud projects add-iam-policy-binding $PROJECT \
--member="serviceAccount:$SA" --role=roles/artifactregistry.writer --condition=None
gcloud projects add-iam-policy-binding $PROJECT \
--member="serviceAccount:$SA" --role=roles/artifactregistry.admin --condition=None

A deployed Cloud Run service runs as its own identity, separate from the deployer account above. Greentic gives every workspace a dedicated one, named gtc-<workspace>-runtime (for example gtc-acme-runtime@acme-prod-1234.iam.gserviceaccount.com), rather than letting services fall back to the project’s default compute service account, which is shared by everything in the project.

Google only lets an account deploy a service that runs as another identity if it holds iam.serviceAccounts.actAs on that identity. So the runtime account needs two things: it must exist, and the deployer must hold roles/iam.serviceAccountUser on it.

With roles/iam.serviceAccountAdmin granted (above), you do nothing. On the first deploy Greentic creates gtc-<workspace>-runtime, grants the deployer roles/iam.serviceAccountUser on that one account, and remembers it for every later deploy.

Without it, the first deploy stops before building anything and shows the two commands to run once, with your project, workspace and deployer filled in:

Terminal window
gcloud iam service-accounts create gtc-acme-runtime \
--project=$PROJECT --display-name='Greentic Cloud Run runtime'
gcloud iam service-accounts add-iam-policy-binding \
gtc-acme-runtime@$PROJECT.iam.gserviceaccount.com \
--project=$PROJECT \
--member="serviceAccount:$SA" --role=roles/iam.serviceAccountUser

Run both and deploy again. Both options are sound — pick one:

Grant roles/iam.serviceAccountAdminRun the two commands
Who actsGreentic, on each new workspace’s first deployYou, once per workspace
Deployer’s IAM powerCan create and manage service accounts in the projectactAs on one named account only
Best whenSeveral workspaces deploy into this projectOne workspace, or a locked-down project
  1. Open the service account, go to the Keys tab, and choose Add key → Create new key.

  2. Pick JSON. The file downloads once and Google keeps no copy.

  3. Open the file and copy its entire contents, braces included.

Terminal window
gcloud iam service-accounts keys create greentic-deployer.json \
--iam-account=$SA --project=$PROJECT

The file must be a service-account key. It looks like this:

{
"type": "service_account",
"project_id": "acme-prod-1234",
"private_key_id": "…",
"private_key": "-----BEGIN PRIVATE KEY-----\n…\n-----END PRIVATE KEY-----\n",
"client_email": "greentic-deployer@acme-prod-1234.iam.gserviceaccount.com",
"client_id": "…",
"token_uri": "https://oauth2.googleapis.com/token"
}

Greentic reads three fields from it — client_email, private_key and token_uri — and requires token_uri to be an https:// URL.

  1. In the Designer, open the Deploy panel and expand Google Cloud Run.

  2. Fill in GCP project id, Cloud Run region, and — if you are not using the default — Artifact Registry repository.

  3. Paste the whole key file into Service-account key JSON.

  4. Click Check permissions.

The check is read-only. It changes nothing in your project and stores nothing; it asks Google what this key is allowed to do, at each of the three scopes, and prints what is missing.

Each scope comes back as one of three answers, and they are deliberately not collapsed into a pass/fail:

  • satisfied — every permission is granted.
  • missing — Google answered, and named permissions are absent. The report offers the gcloud command that grants them.
  • not checked — Google did not answer, so nothing is known. This is not a pass. The commonest cause is an API that is not enabled (see step 1).

If you prefer a custom role to the predefined ones above, this is the full set Greentic probes, and the scope each one is asked about.

run.services.get, run.services.list, run.services.create, run.services.update, run.services.delete, run.services.getIamPolicy, run.services.setIamPolicy, run.revisions.get, run.revisions.list, run.revisions.delete, run.operations.get, secretmanager.secrets.get, secretmanager.secrets.create, secretmanager.secrets.update, secretmanager.versions.add, secretmanager.versions.access, secretmanager.secrets.getIamPolicy, secretmanager.secrets.setIamPolicy, secretmanager.secrets.delete, logging.logEntries.list

Plus five advisory permissions, reported but never counted as a failure:

  • artifactregistry.repositories.create — needed only to create the repository, so a deploy into one that already exists does not need it; on a first run it decides whether the deploy gets far enough to need any of the others (roles/artifactregistry.admin).
  • iam.serviceAccounts.get, iam.serviceAccounts.create, iam.serviceAccounts.getIamPolicy, iam.serviceAccounts.setIamPolicy — needed only to create the runtime service account for you (roles/iam.serviceAccountAdmin). A workspace whose runtime account already exists needs none of them.

artifactregistry.repositories.get, artifactregistry.repositories.downloadArtifacts, artifactregistry.repositories.uploadArtifacts

iam.serviceAccounts.actAs, asked about the runtime service account.

The Designer stores the key encrypted and never shows it again — the panel only reports whether a credential is present. To rotate, use Replace and paste the new key; the old value is overwritten. Delete the superseded key in Google Cloud afterwards:

Terminal window
gcloud iam service-accounts keys list --iam-account=$SA --project=$PROJECT
gcloud iam service-accounts keys delete <KEY_ID> --iam-account=$SA --project=$PROJECT
SymptomCauseFix
Every scope reports not checkedThe APIs are not enabledStep 1
Project scope reports not checked with a 403Cloud Resource Manager is offgcloud services enable cloudresourcemanager.googleapis.com
The key is rejected on pasteIt is an authorized_user file, or a field is blankCreate a service-account key (step 4)
The permission check passes, the deploy fails on pushartifactregistry.repositories.uploadArtifacts was granted at a scope the deploy does not useGrant roles/artifactregistry.writer on the repository and confirm the repository name matches
Service-account scope reports not checkedNo runtime service account exists yetExpected before the first deploy — it is created then (Runtime service account)
The deploy stops and shows gcloud iam service-accounts create gtc-…-runtime plus an add-iam-policy-binding … roles/iam.serviceAccountUserThe deployer cannot create the runtime service accountRun the two commands once, or grant roles/iam.serviceAccountAdmin and deploy again (Runtime service account)
You granted roles/iam.serviceAccountUser and the deploy still shows the same two commandsIt was granted on the project, or the account does not exist yetRun the create command, then bind the role on gtc-<workspace>-runtime itself
The Log tab says Google refused to read logslogging.logEntries.list is missingroles/logging.viewer at project scope