Reputation: 4136
Im trying to pass a secret into a Cloud Run run command. The secret is a json file. I want to pass it in as an environment variable.
It works great in docker using:
docker run -it -e "SECRET_ENV=$(<path/secretFile.json)" -p 8080:8080 my_image
When I use the same method on gcloud I get an error that tells me its trying to run each line of the json file:
gcloud run deploy --image gcr.io/account/project --update-env-vars "SECRET_JSON=$(<path/secretFile.json)"
cheers
Upvotes: 3
Views: 4470
Reputation: 4136
Thanks @Kolban for working through the issue with me.
And
Thanks to @tzovourn for suggestion on berglas secret manager
It appears the GCP gcloud command is bugged and/or does not support JSON.
The solution I used in the end was to base 64 encode the json before setting it as an environment variable. Now docker and gcloud commands take the same data and format.
Upvotes: 3
Reputation: 1321
Currently gcloud run deploy
doesn't support setting environment variables through a json file. More information about environment variables on Cloud Run can be found here.
You may want to file a Feature Request for this improvement.
Upvotes: 3