Home > database >  Create a simple text secret in Google Cloud Secret Manager using CLI
Create a simple text secret in Google Cloud Secret Manager using CLI

Time:11-09

When using the GUI on Google Cloud Console to create a secret all I needed to provide was the secret name and it's value and I'm done.

However, I would like to use the gcloud cli to create simple string secrets.

So far, all the documentations in the docs keep mentioning --data-file like below:

gcloud secrets create sample-secret --data-file="/path/to/file.txt"

How can I use simple strings as the secret value similar to the GUI flow such that I can have a command like

gcloud secrets create apiKey "adadadad181718783"

Must it always be a file?

CodePudding user response:

you could try with this sample command

printf "s3cr3t" | gcloud secrets create my-secret --data-file=-

setting the --data-file=- flag to "-" will read the secret data from stdin.

You can check this documentation for reference

  • Related