<p>I need to supply a Configgroup with yaml. The yaml needs to be populated with values from Pulumi Outputs. My problem is that the yaml field in the code below only take strings and I cannot figure a way to create this string from Outputs.</p>
<p>For example, imagine taking an Id of sorts from an Output and replacing foo.</p>
<p>Any ideas?</p>
<pre><code>import * as k8s from &quot;@pulumi/kubernetes&quot;;

const example = new k8s.yaml.ConfigGroup(&quot;example&quot;, {
    yaml: `
          apiVersion: v1
          kind: Namespace
          metadata:
             name: foo
`,
})
</code></pre>

TomHells
<p>Any time you're needing to use an output value inside a string, you'll need to make sure the output is resolved using an <code>apply</code>.</p>
<p>In your case, it'd look a little bit like this:</p>
<pre class="lang-js prettyprint-override"><code>import * as k8s from &quot;@pulumi/kubernetes&quot;;
import * as pulumi from &quot;@pulumi/pulumi&quot;;

const nsName = pulumi.output(&quot;foo&quot;)

nsName.apply(name =&gt; {
    const example = new k8s.yaml.ConfigGroup(&quot;example&quot;, {
        yaml: `
        apiVersion: v1
        kind: Namespace
        metadata:
           name: ${name}
        `
    })
})
</code></pre>
<p>However, it's usually not desirable to create resources inside an apply like this, because it means previews aren't accurate. If you're just trying to create a namespace, it'd be highly recommend to use the kubernetes provider's namespace resource, instead of <code>ConfigGroup</code> (although I recognise you're trying to get a working example probably for something else)</p>
<p>You might consider using <a href="https://www.pulumi.com/kube2pulumi/" rel="nofollow noreferrer">kube2pulumi</a> to convert whatever YAML you're installing, because once you're using the standard types, you can pass outputs to fields easily, like so:</p>
<pre class="lang-js prettyprint-override"><code>const newNs = new k8s.core.v1.Namespace(&quot;example&quot;, {
    metadata: {
        name: nsName
    }
})
</code></pre>
