---
title: "Example stack README in Pulumi Cloud"
description: "A minimal Java Pulumi program demonstrating Stack Readmes"
url: "https://www.pulumi.com/dev/examples/stack-readme-java/"
image: "https://www.pulumi.com/assets/og/dev/examples/stack-readme-java.png"
---

# Example stack README in Pulumi Cloud

A minimal Java Pulumi program demonstrating Stack Readmes

- Source on GitHub: https://github.com/pulumi/examples/tree/master/stack-readme-java
- Deploy with Pulumi: https://app.pulumi.com/new?template=https%3A%2F%2Fgithub.com%2Fpulumi%2Fexamples%2Ftree%2Fmaster%2Fstack-readme-java

## Get started with this example

This example lives in the [pulumi/examples](https://github.com/pulumi/examples/tree/master/stack-readme-java) repo. Pull down just this directory to follow along:

```bash
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set stack-readme-java
cd pulumi-examples/stack-readme-java
```

This example shows how to set up a [Stack README](https://www.pulumi.com/docs/intro/pulumi-cloud/projects-and-stacks/#stack-readme) in Java.

Stack READMEs in [Pulumi Cloud](https://app.pulumi.com/) 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

`./src/main/java/stackreadme/App.java`

```java
package stackreadme;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

import com.pulumi.Pulumi;
import com.pulumi.core.Output;

public class App {
    public static void main(String[] args) {
        Pulumi.run(ctx -> {
            var strVar = "foo";
            var arrVar = new String[]{ "fizz", "buzz" };
            try {
                var readme = Files.readString(Paths.get("./Pulumi.README.md"));
                ctx.export("strVar", Output.of(strVar));
                ctx.export("arrVar", Output.of(arrVar));
                ctx.export("readme", Output.of(readme));

            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });
    }
}

```

`./Pulumi.README.md`

```markdown
# 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](https://www.pulumi.com/docs/get-started/install/)
2. [Install Java](https://www.pulumi.com/docs/intro/languages/java/)

## Deploying the example

1.  Create a new stack:

    ```bash
    pulumi stack init dev
    ```

1.  Deploy the stack:

    ```bash
    pulumi up
    ```

## Viewing the rendered stack README

Open the stack in the Pulumi Cloud console:

```bash
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:

```bash
pulumi destroy
pulumi stack rm
```
