This topic discusses how to disable a secret version. A secret version can be in one of the following three states:
- Enabled
- Disabled
- Destroyed
When you disable a secret version, it can't be accessed. Disabling a secret is reversible.
Required roles
To get the permissions that you need to disable a secret version,
ask your administrator to grant you the
Secret Manager Secret Version Manager (roles/secretmanager.secretVersionManager
) IAM role on a secret.
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
Disable a secret version
Console
-
Go to the Secret Manager page in the Google Cloud console.
-
On the Secret Manager page, click on the Name of a secret.
-
On the Secret details page, in the Versions table, locate a secret version to access.
-
In the Actions column, click View more
. -
Click Disable from the menu.
-
In the Disable secret version dialog, click the Disable selected versions button.
gcloud
To use Secret Manager on the command line, first Install or upgrade to version 378.0.0 or higher of the Google Cloud CLI. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
$ gcloud secrets versions disable version-id --secret="secret-id"
C#
To run this code, first set up a C# development environment and install the Secret Manager C# SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
Go
To run this code, first set up a Go development environment and install the Secret Manager Go SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
Java
To run this code, first set up a Java development environment and install the Secret Manager Java SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
Node.js
To run this code, first set up a Node.js development environment and install the Secret Manager Node.js SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
PHP
To run this code, first learn about using PHP on Google Cloud and install the Secret Manager PHP SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
Python
To run this code, first set up a Python development environment and install the Secret Manager Python SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
Ruby
To run this code, first set up a Ruby development environment and install the Secret Manager Ruby SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
API
These examples use curl to demonstrate using the API. You can generate access tokens with gcloud auth print-access-token. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.
$ curl "https://secretmanager.googleapis.com/v1/projects/project-id/secrets/secret-id/versions/version-id:disable" \
--request "POST" \
--header "authorization: Bearer $(gcloud auth print-access-token)" \
--header "content-type: application/json"
What's next
- Learn how to enable a disabled version.
- Learn how to destroy a secret version.