Skip to main content
Five Steps for Cloud Compliance Readiness·A practical playbook for security teamsDownload
CIS Google Cloud Platform Foundation v5.0.0 · 1.16

API keys should be rotated at least every 90 days

  • Level 2
  • Identity and Access Management

This check looks at the age of the API keys in your Google Cloud projects. The safe setting is that no key is older than 90 days, so each one is replaced on a regular schedule.

Why it matters

An API key is a long-lived string. It is often pasted into code, config files or mobile apps, and anyone who copies it can use it until it is deleted. Regular replacement limits how long a leaked key stays useful.

Google Cloud's API key documentation tells you to keep key strings secure and to restrict each key by API and by application. Rotation adds a time limit on top of those restrictions. The Google documentation describes rotation in the console. See the source below.

How to check it yourself

In the Google Cloud console open APIs & Services → Credentials and read the Creation date column in the API keys list. Any key older than 90 days fails the check.

With the gcloud CLI, this read-only command lists keys with their creation time (replace the project ID):

gcloud services api-keys list --project=my-project-id \
  --format="table(uid, displayName, createTime)"

Repeat for each project in scope.

How to fix it

Rotate in this order so nothing breaks: create a replacement key with the same restrictions, move every application to it, confirm that traffic uses the new key, then delete the old key. Google documents rotation as a console feature (APIs & Services → Credentials → the key → Rotate key), and the delete step is done there too.

To create the replacement key with gcloud, restrict it to the API it needs:

gcloud services api-keys create \
  --project=my-project-id \
  --display-name="my-app-key-rotated" \
  --api-target=service=maps-backend.googleapis.com

You make these changes yourself. ConfigCobra uses a read-only service account and never creates, changes or deletes keys.

What changes when you fix it

The old key stops working once it is deleted, so any application, script or device still using it starts to fail with an authentication error. List who owns each key before you rotate, update the secret in each system, and watch error rates after the switch.

Google lets you restore a deleted key for 30 days with gcloud services api-keys undelete, which gives you a way back if something was missed. Put the next rotation date in a calendar or ticket, because the check will fail again when the new key reaches 90 days.

Included in

BenchmarkCIS IDProfile
CIS Google Cloud Platform Foundation v5.0.01.16Level 2

Check this on your Google Cloud

ConfigCobra runs this check with every other control of the CIS Google Cloud Platform Foundation Benchmark, read-only.

Get in touch

Let's talk.

Whether you're evaluating ConfigCobra, running an audit, or managing a client fleet — we respond within one business day.

Free trial