In my serverless.yml file, I’m trying to add an environment variable called GOOGLE_APPLICATION_CREDENTIALS which points to my service account credentials JSON file but when added to the serverless file I'm getting an error Environment variable GOOGLE_APPLICATION_CREDENTIALS must contain string
I tried adding the environment variable GOOGLE_APPLICATION_CREDENTIALS using AWS CLI and it worked fine. But I want to add the environment variable from serverless file.
I’ve tried the below methods but none of the method seem to work
environment:
GOOGLE_APPLICATION_CREDENTIALS: ‘${file(./serviceAccountCreds.json)}’
environment:
GOOGLE_APPLICATION_CREDENTIALS: “${file(./serviceAccountCreds.json)}”
environment:
GOOGLE_APPLICATION_CREDENTIALS: ${file(./serviceAccountCreds.json)}
My use case is I need to load the google application credentials to call the GCP APIs from the AWS lambda. I’ve read answers regarding support for google cloud functions for setting the environment variable but doesn’t seem to help with the AWS functions. Not sure the support in generic one or only to GCP functions.
Edited : Tried setting the environment variable at the run time process.env.GOOGLE_APPLICATION_CREDENTIALS
as well and worked. But this still leaves me with a question whether the serverless has support of setting env.variables to JSON files as a whole.
Links I followed: