Search code examples
google-cloud-platformgcloudgoogle-cloud-run

Escaping characters in a list sent as environment variable to GCP Cloud Run


I am trying to create a Github workflow about deploying a GCP Cloud Run service with a list of strings as environment variable and need help defining the environment variable properly with regards to the the escaping of characters.

Here's my gcloud command:

gcloud run deploy my-service --image \
       europe-west1-docker.pkg.dev/projectName/containers/my-service:$(echo ${GITHUB_SHA} | cut -c1-8) \
       --project PROJECT --platform managed --region europe-west3 \
       --memory 4Gi \
       --timeout 900 \
       --set-env-vars="my_list=["one", "two", "three"]" 

I would appreciate some help defining the syntax of the environment variable my_list.

Many thanks in advance.


Solution

  • You could make use of an environment variable file as described here. Doing so would replace --set-env-vars with --env-vars-file and use an environment variable file to specify the value for my_list.

    An example of how the command would change:

    --env-vars-file=variable.yaml
    

    An example of how the variable would be defined in the file:

    my_list:["one", "two", "three"]