Skip to main content

Search the Dev Center

Search tutorials, templates, examples, and more.

Example stack README in Pulumi Cloud

A minimal Stack Readme Go Example program

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set stack-readme-go
cd pulumi-examples/stack-readme-go

This example shows how to set up a Stack README in Go.

Stack READMEs in Pulumi Cloud dynamically update based on Stack Outputs. Stack READMEs interpolate output variables on the stack (${outputs.instances[0].ARN}) so that each stack can construct links to dashboards, shell commands, and other pieces of documentation. All of this content stays up to date as you stand up new stacks, rename resources, and refactor your infrastructure.

To set a Stack README, simply set a Stack Output named readme to the value of your templated Stack README file. In this example, we’ve called the file Pulumi.README.md.

Example project structure#

./main.go

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
strVar := "foo"
arrVar := []string{"fizz", "buzz"}
readmeBytes, err := ioutil.ReadFile("./Pulumi.README.md")
if err != nil {
return fmt.Errorf("failed to read readme: %w", err)
}
ctx.Export("strVar", pulumi.String(strVar))
ctx.Export("arrVar", pulumi.ToStringArray(arrVar))
ctx.Export("readme", pulumi.String(string(readmeBytes)))
return nil
})
}

./Pulumi.README.md

# Stack README
Full markdown support! Substitute stack outputs dynamically so that links can depend on your infrastructure! Link to dashboards, logs, metrics, and more.
1. Reference a string stack output: ${outputs.strVar}
2. Reference an array stack output: ${outputs.arrVar[1]}

Prerequisites#

  1. Install Pulumi
  2. Install Go

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Install dependencies:

    Terminal window
    go mod download
  3. Deploy the stack:

    Terminal window
    pulumi up

Viewing the rendered stack README#

Open the stack in the Pulumi Cloud console:

Terminal window
pulumi console

Then click the README tab to see the rendered Stack README with your stack outputs interpolated.

Cleaning up#

Once you’re finished experimenting, you can destroy your stack and remove it:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.