Fork me on GitHub

Stack exports

It can be handy to export values from your stacks.

Exporting a value simply records its final value anytime you perform a deployment. These values are typically output properties from resources, but they can be anything.

For instance, the following code creates a VM and exports its auto-assigned public IP address:

var aws = require("@pulumi/aws");
var server = new aws.ec2.Instance("my-vm", {
    ami: "ami-7172b611",
    instanceType: "t2.micro",
exports.ipAddress = server.publicIp;
import * as aws from "@pulumi/aws";
let aws = require("@pulumi/aws");
let server = new aws.ec2.Instance("my-vm", {
    ami: "ami-7172b611",
    instanceType: "t2.micro",
export let ipAddress = server.publicIp;
import pulumi
from pulumi_aws import ec2
server = ec2.Instance('my-vm', {
pulumi.output('ipAddress', server.publicIp)
package main

import (

func main() {
    pulumi.Run(func (ctx *pulumi.Context) error {
        server, err := ec2.NewInstancectx, "my-vm", &ec2.InstanceArgs{
            Ami:          "ami-7172b611",
            InstanceType: "t2.micro",
        if err != nil {
            return err
        pulumi.Export("ipAddress", server.PublicIp)
        return nil

After deploying this program with pulumi update, the exports will be printed, including any diffs.

And the pulumi stack output command may be used to retrieve all of them:

$ pulumi stack output
Current stack outputs (1):
    OUTPUT                  VALUE

Or even a specific value:

$ pulumi stack output ipAddress

This command was designed to make scripting against the pulumi CLI easy, for instance if you need to plug that IP address into another command as part of your automation, like curling or sshing into it.

This concludes the second lesson of the tour. If there are topics you’d like to see added in the future, please get in touch. Feel free to file suggestions as issues directly in our pulumi/docs repo.

If you’re ready to start programming the cloud, check out the tutorials next!