Hi! I’m trying out the automation API with an inli...
# automation-api
b
Hi! I’m trying out the automation API with an inline TypeScript program, and I’m loving it so far! There is one thing I can’t figure out, though: How do I register stack outputs? I’m migrating an existing stack from a regular project to using the automation API, and I got all the resources working. However, when I run
stack.preview(…)
, it wants to delete my stack outputs. Fair enough, I didn’t really do anything to export my stack outputs from the inline program. I’ve tried a few things: 1. Returning values from my
program
function 2. Creating a new Stack resource, and returning values from the
init
function 3. Asking the Pulumi AI. It told me to call
stack.export(…)
, which doesn’t exist. Then it said to call
pulumi.export(…)
, which also doesn’t exist. Finally, it told me to use
pulumi.output(…)
, which… does not do what I want I also looked at the Automation API examples repo, and found two seemingly relevant examples – [nodejs/crossLanguage-tsnode](https://github.com/pulumi/automation-api-examples/tree/124e3e3ed839f1dc026f686e826b6b646d9f136a/nodejs/crossLanguage-tsnode) and [go/multi_stack_orchestration](https://github.com/pulumi/automation-api-examples/tree/124e3e3ed839f1dc026f686e826b6b646d9f136a/go/multi_stack_orchestration) – but in both examples, the program that actually exports stack outputs is written in Go, and exports outputs with
ctx.Export(…)
, which doesn’t really have a TypeScript equivlent 😅 Does anyone have any suggestions? 😄 😄 😄
e
1. Returning values from my
program
function
Should be that one. Return something like
{myOutput: true}
.
e.g. a mini program from the tests:
Copy code
const program = async () => {
            const config = new Config();
            return {
                exp_static: "foo",
                exp_cfg: config.get("bar"),
                exp_secret: config.getSecret("buzz"),
            };
        };
b
Hmm, I’ll try that again. Thanks! I’ll let you know 😄
Well, that just worked. No idea why I thought it didn’t – I must have done something wrong last night. Thank you so much!!