3

I'm using the Pulumi Automation API in Go, and I want to format the standard output (stdout) as JSON. Currently, I handle stdout like this:

stdoutStreamer := optup.ProgressStreams(os.Stdout)
_, err = stack.Up(context.Background(), stdoutStreamer)
if err != nil {
    log.Fatalf("Failed to update stack: %v\n\n", err)
}

Is there a simple and easy way to have the output formatted as JSON? Any suggestions or examples would be greatly appreciated. Thanks in advance

3
  • 2
    The first hit of this search query explains how to create "something" which can be passed to stack.Up as its second argument. You can easily adapt that example to output JSON-formatted data. Commented May 6, 2024 at 13:57
  • There seems to be no equivalent of pulumi up -j option in go automation API. pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/auto/optup . Is there a workaround? Anyone? Commented Dec 20, 2024 at 13:28
  • Thanks @kostix . adding the exact section here that shows the code example you wanted to show - pulumi.com/blog/observability-with-infrastructure-as-code/… . This does text parsing on the printed lines. Commented Dec 20, 2024 at 13:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.