Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCP: Cloud Function app.yaml file for environmental variables formatting issue

I am attempting to deploy a GCP cloud function using the "--env-vars-file" flag and specifying a YAML file to contain the variables. My 'app-dev.yaml' YAML file looks like this:

runtime: python37
api_version: '1'
threadsafe: 'true'

env_variables:
  VAR_1: 'var_1_value'
  VAR_2: 'var_2_value'
  VAR_3: 'var_3_value'

And my gcloud functions deploy looks like this:

gcloud functions deploy my_cloud_function --env-vars-file app-dev.yaml --runtime python37 --trigger-resource my-project.appspot.com --trigger-event google.storage.object.finalize

Now when I run this command I get back this error:

gcloud crashed (ValidationError): Expected type for field value, found {'VAR_1': 'var_1_value', 'VAR_2': 'var_2_value', 'VAR_3': 'var_3_value'} (type <type 'dict'>)

But according to this Google example the app-dev.yaml format should be fine.

Any help is appreciated. Thanks

like image 475
Gatmando Avatar asked Sep 03 '25 15:09

Gatmando


2 Answers

All values must be strings, example:

Wrong value:

VAR_1: 3.1416

Correct value:

VAR_1: "3.1416"
like image 71
Vladymir Gonzalez Avatar answered Sep 05 '25 15:09

Vladymir Gonzalez


The link you provided refers to the app.yaml file needed in App Engine and is unrelated.

As per the Cloud Functions doc here, the .env.yaml file should have the following format:

VAR_1: var_1_value
VAR_2: var_2_value
VAR_3: var_3_value
like image 38
LundinCast Avatar answered Sep 05 '25 15:09

LundinCast