Workaround for Accessing config_context in a Mistral Workflow

Reference

Problem
Currently in a Mistral Workflow you can not access the config_context described here: Actions — StackStorm 2.10.1 documentation

StackStorm currently doesn’t pass this context into Mistral or provide a Jinja filter to access it.

Workaround
To access the config context information in a Mistral workflow, you can simply create a new parameter in the StackStorm action metadata. This new paramter can be immutable parameter and set with default that reads from the config context.

Example :

Action metadata file

parameters:
    config_username:
        type: "string"
        description: "Username from the pack's config"
        required: true
        immutable: true
        default: "{{ config_context.username }}"

Finally, add this new parameter as an input in your Mistral workflow, then you can access it like a normal Mistral variable.

examples.config_context_example:
  description: 
  type: direct
  input:
    - config_username

  tasks:
    action: core.local
    input:
      cmd: "echo {{ _.config_username }}"

We have added a task to just fetch the pack config in the workflow.

pack_config:
    action: core.http
    input:
      url: "{{ env().st2_action_api_url }}/configs/{{ env()['__actions']['st2.action']['st2_context']['parent']['pack'] }}"
      method: GET
      headers:
        X-Auth-Token: "{{ env()['__actions']['st2.action']['st2_context']['auth_token'] }}"
   on-success:
      - call_next_task

Later, you can define input or output to tasks / workflows like so:

      schema_registry_url: '<% task(pack_config).result.body.values.kafka_schema_registry_url %>'
      bootstrap_servers:   "{{ task('pack_config')['result']['body']['values']['kafka_bootstrap_servers'] }}"

Attempting to reproduce this above in orquesta - but the env() appears not to be a function there. Is there a list of all the system functions / data structures availalbe for orquesta ? I have seached the docs to no avail.

Try this doc section on StackStorm Context and Functions