Search code examples
pythonibm-cloudserverlessibm-cloud-code-engine

IBM Cloud Code Engine: How to determine app URL from environment?


I have a Python app deployed to IBM Cloud Code Engine. The app needs to determine its external URL for some security configuration. How can I obtain the app URL from the environment?

I looked at the list of injected environment variables, but could not find anything.


Solution

  • We just recently added some new environment variables to help with this. Depending on which region you're in they should be available today, but worst case by next week.

    The new env vars you want to look for are:

    • CE_APP: the application name
    • CE_SUBDOMAIN: the subdomain (or kube namespace if you're interested) of the app/project
    • CE_DOMAIN: the domain name of the app/project you're running in.

    So the full URL would be: https://${CE_APP}.${CE_SUBDOMAIN}.${CE_DOMAIN}

    If you happen to be using JOBS then there's:

    • CE_JOB: the job associated with the job run, if there is a Job
    • CE_JOBRUN: the job run name