gcloud secrets versions access latest --secret my-api-key

Category: Google Cloud & Workspace

gcloud secrets versions access latest --secret my-api-key

Print the latest secret value

Outputs the newest version's value of my-api-key to the terminal, which is how scripts read secrets at runtime. Anyone holding the roles/secretmanager.secretAccessor role can do this, so keep output out of logs. List all versions with gcloud secrets versions list.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.