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 accountmy-runtime@acme-prod-1234.iam.gserviceaccount.comRuntime service account (optional)

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

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

Only if you set a runtime service account — the identity the deployed Cloud Run service itself runs as. Deploying a service that runs as another identity requires permission to impersonate it:

Terminal window
gcloud iam service-accounts add-iam-policy-binding \
my-runtime@$PROJECT.iam.gserviceaccount.com \
--project=$PROJECT \
--member="serviceAccount:$SA" --role=roles/iam.serviceAccountUser

Leave the runtime service account blank and Cloud Run uses the project’s default compute service account. Greentic cannot check actAs in that case — it does not know the default account’s address — so that scope reports as not checked rather than as satisfied.

  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.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

Plus one advisory permission, reported but never counted as a failure: artifactregistry.repositories.create. It is needed only to create the repository, so a deploy into one that already exists does not need it — but on a first run it is the permission that decides whether the deploy gets far enough to need any of the others.

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 is setExpected — leave it, or set one and grant roles/iam.serviceAccountUser