Question

Difficulty: MediumSecrets Management and Service Account Lifecycle Security

An enterprise security team needs to establish automated secret rotation for database credentials stored in GCP Secret Manager according to Google Cloud recommended security practices. What is the correct sequence of steps to configure this automated rotation workflow?

  1. 1Create a Pub/Sub topic designated for transmitting secret rotation notification messages.
  2. 2Grant the Secret Manager Service Agent the Pub/Sub Publisher (roles/pubsub.publisher) role on the created Pub/Sub topic.
  3. 3Deploy the rotation Cloud Function that generates new credentials and creates a new secret version.
  4. 4Grant the Cloud Function runtime service account the Secret Manager Secret Version Manager (roles/secretmanager.secretVersionManager) role.
  5. 5Configure the rotation schedule and Pub/Sub topic reference on the target secret in Secret Manager.

Answer

The correct sequence starts with creating the Pub/Sub topic, granting the Secret Manager Service Agent the Pub/Sub Publisher role on that topic, deploying the rotation Cloud Function, granting its runtime service account the Secret Manager Secret Version Manager role, and finally configuring the rotation schedule on the target secret in Secret Manager.
To set up automated secret rotation in GCP Secret Manager using Cloud Functions, resources and permissions must be provisioned in dependency order. First, the Pub/Sub topic must be created to receive rotation events. Next, the Secret Manager Service Agent requires the Pub/Sub Publisher role on that topic. Then, the rotation Cloud Function is deployed, and its dedicated runtime service account is granted the Secret Manager Secret Version Manager role under least-privilege principles. Finally, the target secret in Secret Manager is updated with the rotation schedule pointing to the Pub/Sub topic.

Step-by-Step Solution

1
Create the Pub/Sub topic
The messaging channel for rotation notifications is established.
Pub/Sub acts as the decoupled notification layer between Secret Manager and the rotation worker function.
2
Grant publisher permissions to the Secret Manager Service Agent
Secret Manager is authorized to publish rotation events to the Pub/Sub topic.
Without roles/pubsub.publisher on the topic, Secret Manager cannot send rotation triggers.
3
Deploy the rotation Cloud Function
The function handling credential generation and database updates is deployed.
The Cloud Function logic must exist to process incoming Pub/Sub rotation events.
4
Grant IAM roles to the Cloud Function's runtime service account
The function has least-privilege permissions (roles/secretmanager.secretVersionManager) to write new secret versions.
The function service account must be empowered to update Secret Manager with the newly generated credential versions.
5
Enable rotation schedule on the Secret Manager secret
Automated secret rotation lifecycle is activated.
Linking the secret to the Pub/Sub topic and defining the rotation interval triggers automated execution.

Key Concept

Secret Manager Automated Secret Rotation Architecture and Service Account Least Privilege Lifecycle
Rate this question