Skip to main content

My declaragent deploy got 403

The single most common Cloud Run failure. gcloud run services replace returns HTTP 403 + a cryptic Permission 'run.services.create' denied.

Flowchart

The three IAM roles that matter

The §9.2 preflight checks these:

RoleWhy it's needed
roles/run.adminCreate + update the Cloud Run service.
roles/iam.serviceAccountUserAttach a service account to a Cloud Run revision.
roles/secretmanager.secretAccessorBind ${secret:...} refs into env vars.

If your deploying principal is missing any of these, declaragent deploy --verify will tell you which before gcloud has a chance to 403 you.

Quick fixes

# The deploying principal — usually your gcloud user.
PRINCIPAL="user:[email protected]"
PROJECT="my-project"

gcloud projects add-iam-policy-binding "$PROJECT" \
--member="$PRINCIPAL" --role="roles/run.admin"
gcloud projects add-iam-policy-binding "$PROJECT" \
--member="$PRINCIPAL" --role="roles/iam.serviceAccountUser"
gcloud projects add-iam-policy-binding "$PROJECT" \
--member="$PRINCIPAL" --role="roles/secretmanager.secretAccessor"

Still stuck

  • Run declaragent deploy gcp-cloud-run --verify and paste the full output into a GitHub issue — the preflight message is the most diagnostic piece.
  • Confirm the Dockerfile + service.yaml generators emitted the expected secret bindings by inspecting .declaragent/deploy/service.yaml.