moirK
moirK

Reputation: 681

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.

Upvotes: 1

Views: 1521

Answers (2)

user.dz
user.dz

Reputation: 1032

Another approach would be gcloud topic escaping, Example:

gcloud compute instances create example-instance1 \
--metadata ^:^key1="value1":key2=value2:key3=value3Index1,value3Index2,valueIndex3:key4=value4

Upvotes: 0

JdM
JdM

Reputation: 56

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"]

Upvotes: 2

Related Questions