0

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.

gd1
  • 655
  • 1
  • 10
  • 21
  • Does it work if you change `MY_RESOURCE:${MY_RESOURCE}` in manifest.yml to an actual value then push? I guess the first thing you want to validate is that your env variable is actually set. You could also run `cf env ` after the fact to confirm that the env is set the way you expect. – Daniel Mikusa Jan 12 '21 at 17:59
  • As a side note, I do not believe that bash interpolation will happen with env variables, so you set `MY_RESOURCE:${MY_RESOURCE}`, I believe you'll get the literal string `${MY_RESOURCE}`. What you can do though is to use `(( my_resource ))` in your manifest.yml and then add the `--var` for `--vars-file` args to pass in a file with actual values. You could then vary the vars per env. See https://docs.cloudfoundry.org/devguide/deploy-apps/manifest-attributes.html#variable-substitution – Daniel Mikusa Jan 12 '21 at 18:00

0 Answers0