Question

Difficulty: MediumSecrets Management and Service Account Lifecycle Security

An enterprise security architecture team needs to implement automated, event-driven secret rotation for database credentials using GCP Secret Manager, Cloud Pub/Sub, and a Cloud Run function. What is the correct sequence of steps to configure this automated rotation workflow?

  1. 1Deploy a Cloud Run function containing the secret rotation logic and grant it permissions to access and update Secret Manager versions.
  2. 2Create a Cloud Pub/Sub topic designated to receive rotation notification events from Secret Manager.
  3. 3Grant the Secret Manager Service Agent the Pub/Sub Publisher role (roles/pubsub.publisher) on the newly created Pub/Sub topic.
  4. 4Configure an Eventarc trigger or Pub/Sub subscription to invoke the Cloud Run function upon receiving messages on the Pub/Sub topic.
  5. 5Configure the secret in Secret Manager with a rotation schedule interval and associate it with the Pub/Sub topic.

Answer

The correct sequence begins with deploying the Cloud Run rotation function, creating the target Pub/Sub topic, granting the Secret Manager Service Agent publisher permissions on that topic, subscribing the Cloud Run function to the topic, and finally enabling the rotation schedule on the secret linked to the topic.
Automated secret rotation in Google Cloud follows an event-driven pub/sub architectural model. First, the worker component (Cloud Run function) that interacts with database APIs and Secret Manager versions must be deployed. Second, a Pub/Sub topic acts as the event broker. Third, Secret Manager's service agent requires the Pub/Sub Publisher role on the topic to emit rotation events. Fourth, the Cloud Run function is subscribed to the topic so event delivery triggers rotation logic. Finally, setting the rotation frequency on the secret itself initiates the automated lifecycle.

Step-by-Step Solution

1
Deploy the rotation application logic
The Cloud Run function is ready to handle credential regeneration and payload versioning.
The rotation target must exist prior to configuring event bindings and notification triggers.
2
Create the event messaging topic
A Pub/Sub topic is provisioned to receive rotation signals.
Secret Manager relies on Pub/Sub topics as event sinks for rotation notifications.
3
Authorize the Secret Manager Service Agent
The service agent for Secret Manager gains `roles/pubsub.publisher` on the Pub/Sub topic.
By default, Secret Manager cannot publish notification messages to custom Pub/Sub topics without explicit IAM permission.
4
Bind the Pub/Sub topic to the Cloud Run function
An Eventarc trigger or Pub/Sub subscription connects the topic to the function.
This establishes the trigger path so published rotation events immediately execute the function code.
5
Enable rotation schedule on the secret
Secret Manager starts tracking rotation intervals and publishing events.
Attaching the topic and rotation schedule to the secret completes the workflow and starts automated rotation.

Key Concept

Secret Manager Event-Driven Automated Rotation Lifecycle
Rate this question