How to use Google Cloud Run ENV variables in local development environment?

254 Views Asked by At

How to use Google Cloud Run ENV variables in local development environment?

I have a Google Cloud Run deployment with ENV variables that I created inside Google Cloud Console.

ENV Variable inside cloud run

I installed the Google Cloud SDK in order to be able to test my code locally, everything seems to be working besides the ENV variables, for example when I do:

BUCKET = os.environ.get('BUCKET_NAME')
print(f'Bucket Name from Environment Variable: {BUCKET}')

It prints:

Bucket Name from Environment Variable: None

I also tried to set .env file with this variable and same thing happens:

Bucket Name from Environment Variable: None

So how should I use it locally?

1

There are 1 best solutions below

0
Snir Ego On

Found the problem, the only reason it did not work is because I did not have python-dotenv installed:

pip install python-dotenv

Thank you!