Access environment variable defined on jules.yml through code

1.7k views Asked by At

I have a flask application and the jules pipeline to be hosted into Gaia cloud using cloudfoundry.

Manisfest.yml

---
applications:
- name: my_app
  path: ./
  buildpacks:
  -python_buildpack
  command: python my_app/abc.py
  env:
    MY_RESOURCE:${MY_RESOURCE}

jules.yml

---
project specific congfiguration
mapping
  - name: develop
    gaiaspace:
      - space: dev
        overrides:
          - MY_RESOURCE, '12345'
      - space: test:
        overrides:
          - MY_RESOURCE, '67890'

MY_RESOURCE change according to the space(dev, uat or prod), so in the Python code I want the correct value of MY_RESOURCE according to the space where it is deployed. My python code

abc.py

import os

my_resource = os.environ.get('MY_RESOURCE')
print(my_resource)

Even I tried using environs as

from environs import Env
my_env = Env()
my_resource = my_env.str(MY_RESOURCE)
print(my_resource)

but no luck. Let's say I am deploying it on DEV and expect the output as 12345 but not able to get it.

0

There are 0 answers