0

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?

ololo
  • 1,326
  • 2
  • 14
  • 47

1 Answers1

1

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

Siegfred V.
  • 1,143
  • 3
  • 12