Cloud scheduler permission denied

From divinevideo/divine-mobile · View interactive version

Cloud scheduler permission denied is an AI agent skill from the GitHub repository divinevideo/divine-mobile. Fix Google Cloud Scheduler silently failing to trigger Cloud Run jobs with status code 7 (PERMISSION_DENIED). Use when: (1) Cloud Run jobs stop running but schedulers show ENABLED, (2) gcloud scheduler jobs describe shows lastAttemptTime but status.code: 7, (3) Jobs worked before but stopped after I

How to use this skill

Skill file

Cloud Scheduler Permission Denied (Code 7)

Problem

Cloud Scheduler jobs silently fail to trigger Cloud Run jobs. The scheduler shows as

ENABLED, attempts are made (lastAttemptTime updates), but Cloud Run jobs never start.

The only indicator is status.code: 7 which means PERMISSION_DENIED.

Context / Trigger Conditions

```

lastAttemptTime: '2026-02-08T14:00:03.316530Z'

state: ENABLED

status:

code: 7

```

Solution

  1. Identify the scheduler's service account:

```bash

gcloud scheduler jobs describe <scheduler-name> \

--location=<region> \

--project=<project> \

--format="yaml(httpTarget.oauthToken.serviceAccountEmail)"

```

  1. Grant run.invoker role to that service account:

```bash

gcloud projects add-iam-policy-binding <project-id> \

--member="serviceAccount:<service-account-email>" \

--role="roles/run.invoker"

```

  1. Test by manually triggering the scheduler:

```bash

gcloud scheduler jobs run <scheduler-name> \

--location=<region> \

--project=<project>

```

  1. Verify the Cloud Run job started:

```bash

gcloud run jobs executions list \

--region=<region> \

--project=<project> \

--limit=5

```

Verification

After granting permissions and triggering:

Example

# Check scheduler status - note code: 7
gcloud scheduler jobs describe profile-crawler-schedule \
  --location=us-central1 \
  --project=my-project

# Grant permission
gcloud projects add-iam-policy-binding my-project \
  --member="serviceAccount:my-scheduler@my-project.iam.gserviceaccount.com" \
  --role="roles/run.invoker"

# Test
gcloud scheduler jobs run profile-crawler-schedule \
  --location=us-central1 \
  --project=my-project

Notes

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.