<p>I've Two workflowTemplates <code>generate-output</code>, <code>lib-read-outputs</code> and One workflow <code>output-paramter</code> as follows</p>
<ol>
<li><code>generate-output.yaml</code></li>
</ol>
<pre><code>apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: generate-output
spec:
  entrypoint: main
  templates:
    - name: main
      dag:
        tasks:

          # Generate Json for Outputs
          - name: read-outputs
            arguments:
              parameters:
                - name: outdata
                  value: |
                    {
                      &quot;version&quot;: 4,
                      &quot;terraform_version&quot;: &quot;0.14.11&quot;,
                      &quot;serial&quot;: 0,
                      &quot;lineage&quot;: &quot;732322df-5bd43-6e92-8f46-56c0dddwe83cb4&quot;,
                      &quot;outputs&quot;: {
                        &quot;key_alias_arn&quot;: {
                          &quot;value&quot;: &quot;arn:aws:kms:us-west-2:123456789:alias/tetsing-key&quot;,
                          &quot;type&quot;: &quot;string&quot;,
                          &quot;sensitive&quot;: true
                        },
                        &quot;key_arn&quot;: {
                          &quot;value&quot;: &quot;arn:aws:kms:us-west-2:123456789:alias/tetsing-key&quot;,
                          &quot;type&quot;: &quot;string&quot;,
                          &quot;sensitive&quot;: true
                        }
                      }
                    }
            template: retrieve-outputs

    # Create Json
    - name: retrieve-outputs
      inputs:
        parameters:
          - name: outdata
      script:
        image: python
        command: [python]
        env:
          - name: OUTDATA
            value: &quot;{{inputs.parameters.outdata}}&quot;
        source: |
          import json
          import os
          OUTDATA = json.loads(os.environ[&quot;OUTDATA&quot;])
          with open('/tmp/templates_lst.json', 'w') as outfile:
            outfile.write(str(json.dumps(OUTDATA['outputs'])))
        volumeMounts:
          - name: out
            mountPath: /tmp
      volumes:
        - name: out
          emptyDir: { }
      outputs:
        parameters:
          - name: message
            valueFrom:
              path: /tmp/templates_lst.json

</code></pre>
<ol start="2">
<li><code>lib-read-outputs.yaml</code></li>
</ol>
<pre><code>apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: lib-read-outputs
spec:
  entrypoint: main
  templates:
    - name: main
      dag:
        tasks:
          # Read Outputs
          - name: lib-wft
            templateRef:
              name: generate-output
              template: main
</code></pre>
<ol start="3">
<li><code>output-paramter.yaml</code></li>
</ol>
<pre><code>apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: output-paramter-
spec:
  entrypoint: main
  templates:
    - name: main
      dag:
        tasks:
          # Json Output data task1
          - name: wf
            templateRef:
              name: lib-read-outputs
              template: main

          - name: lib-wf2
            dependencies: [wf]
            arguments:
              parameters:
                - name: outputResult
                  value: &quot;{{tasks.wf.outputs.parameters.message}}&quot;
            template: whalesay

    - name: whalesay
      inputs:
        parameters:
          - name: outputResult
      container:
        image: docker/whalesay:latest
        command: [cowsay]
        args: [&quot;{{inputs.parameters.outputResult}}&quot;]
</code></pre>
<p>I am trying to pass the output parameters generated in workflowTemplate <code>generate-output</code> to workflow <code>output-paramter</code> via <code>lib-read-outputs</code></p>
<p>When I execute them, it's giving the following error - <code>Failed: invalid spec: templates.main.tasks.lib-wf2 failed to resolve {{tasks.wf.outputs.parameters.message}}</code></p>

Biru
<h1>DAG and steps templates don't produce outputs by default</h1>
<p>DAG and steps templates do not automatically produce their child templates' outputs, even if there is only one child template.</p>
<p>For example, the <code>no-parameters</code> template here does not produce an output, even though it invokes a template which <em>does</em> have an output.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
spec:
  templates:
  - name: no-parameters
    dag:
      tasks:
      - name: get-a-parameter
        template: get-a-parameter
</code></pre>
<p>This lack of outputs makes sense if you consider a DAG template with multiple tasks:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
spec:
  templates:
  - name: no-parameters
    dag:
      tasks:
      - name: get-a-parameter
        template: get-a-parameter
      - name: get-another-parameter
        depends: get-a-parameter
        template: get-another-parameter
</code></pre>
<p>Which task's outputs should <code>no-parameters</code> produce? Since it's unclear, DAG and steps templates simply do not produce outputs by default.</p>
<p>You can think of templates as being like functions. You wouldn't expect a function to implicitly return the output of a function it calls.</p>
<pre class="lang-py prettyprint-override"><code>def get_a_string():
    return &quot;Hello, world!&quot;

def call_get_a_string():
    get_a_string()

print(call_get_a_string())  # This prints nothing.
</code></pre>
<h1>But a DAG or steps template can <em>forward</em> outputs</h1>
<p>You can make a DAG or a steps template <em>forward</em> an output by setting its <code>outputs</code> field.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: get-parameters-wftmpl
spec:
  templates:
  - name: get-parameters
    dag:
      tasks:
      - name: get-a-parameter
        template: get-a-parameter
      - name: get-another-parameter
        depends: get-a-parameter
        template: get-another-parameter
    # This is the critical part!
    outputs:
      parameters:
      - name: parameter-1
        valueFrom: 
          expression: &quot;tasks['get-a-parameter'].outputs.parameters['parameter-name']&quot;
      - name: parameter-2
        valueFrom: 
          expression: &quot;tasks['get-another-parameter'].outputs.parameters['parameter-name']&quot;
---
apiVersion: argoproj.io/v1alpha1
kind: Workflow
spec:
  templates:
  - name: print-parameter
    dag:
      tasks:
      - name: get-parameters
        templateRef:
          name: get-parameters-wftmpl
          template: get-parameters 
      - name: print-parameter
        depends: get-parameters
        template: print-parameter
        arguments:
          parameters:
          - name: parameter
            value: &quot;{{tasks.get-parameters.outputs.parameters.parameter-1}}&quot;
</code></pre>
<p>To continue the Python analogy:</p>
<pre class="lang-py prettyprint-override"><code>def get_a_string():
    return &quot;Hello, world!&quot;

def call_get_a_string():
    return get_a_string()  # Add 'return'.

print(call_get_a_string())  # This prints &quot;Hello, world!&quot;.
</code></pre>
<h1>So, in your specific case...</h1>
<ol>
<li><p>Add an <code>outputs</code> section to the <code>main</code> template in the <code>generate-parameter</code> WorkflowTemplate to forward the output parameter from the <code>retrieve-parameters</code> template.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: generate-parameter
spec:
  entrypoint: main
  templates:
    - name: main
      outputs:
        parameters:
          - name: message
            valueFrom: 
              expression: &quot;tasks['read-parameters'].outputs.parameters.message&quot;
      dag:
        tasks:
          # ... the rest of the file ...

</code></pre>
</li>
<li><p>Add an <code>outputs</code> section to the <code>main</code> template in the <code>lib-read-parameters</code> WorkflowTemplate to forward <code>generate-parameter</code>'s parameter.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: lib-read-parameters
spec:
  entrypoint: main
  templates:
    - name: main
      outputs:
        parameters:
          - name: message
            valueFrom:
              expression: &quot;tasks['lib-wft'].outputs.parameters.message&quot;
      dag:
        tasks:
          # ... the rest of the file ...
</code></pre>
</li>
</ol>
