Accessing a secret
Accessing a secret version returns the secret contents as well as additional metadata about the secret version. When you access a secret version, you specify its version-id
. You can also access the latest version of a secret by specifying latest
as the version.
Accessing a secret version requires the secretmanager.secretAccessor
IAM role. Typically, this role is granted to the service account used by your application.
The following is a gcloud
command that can be used to access a particular version of the secret. However, a common method is to use application libraries for access, as you will see later in the section:
gcloud secrets versions access version-id --secret="secret-id"
You can also use the latest
keyword to get the current version, but this is not a recommended best practice.
Accessing a binary secret version
You can access binary secrets directly but note that Cloud SDK formats the output as UTF-8, which can corrupt binary...