The Cloud Engineering Summit replay is available! See all your favorite talks, on demand. Watch Now

GetStack

The CloudFormation Stack data source allows access to stack outputs and other useful data including the template body.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var network = Output.Create(Aws.CloudFormation.GetStack.InvokeAsync(new Aws.CloudFormation.GetStackArgs
        {
            Name = "my-network-stack",
        }));
        var web = new Aws.Ec2.Instance("web", new Aws.Ec2.InstanceArgs
        {
            Ami = "ami-abb07bcb",
            InstanceType = "t2.micro",
            SubnetId = network.Apply(network => network.Outputs.SubnetId),
            Tags = 
            {
                { "Name", "HelloWorld" },
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v3/go/aws/cloudformation"
    "github.com/pulumi/pulumi-aws/sdk/v3/go/aws/ec2"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        network, err := cloudformation.LookupStack(ctx, &cloudformation.LookupStackArgs{
            Name: "my-network-stack",
        }, nil)
        if err != nil {
            return err
        }
        _, err = ec2.NewInstance(ctx, "web", &ec2.InstanceArgs{
            Ami:          pulumi.String("ami-abb07bcb"),
            InstanceType: pulumi.String("t2.micro"),
            SubnetId:     pulumi.String(network.Outputs.SubnetId),
            Tags: pulumi.StringMap{
                "Name": pulumi.String("HelloWorld"),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

network = aws.cloudformation.get_stack(name="my-network-stack")
web = aws.ec2.Instance("web",
    ami="ami-abb07bcb",
    instance_type="t2.micro",
    subnet_id=network.outputs["SubnetId"],
    tags={
        "Name": "HelloWorld",
    })
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const network = aws.cloudformation.getStack({
    name: "my-network-stack",
});
const web = new aws.ec2.Instance("web", {
    ami: "ami-abb07bcb",
    instanceType: "t2.micro",
    subnetId: network.then(network => network.outputs.SubnetId),
    tags: {
        Name: "HelloWorld",
    },
});

Using GetStack

function getStack(args: GetStackArgs, opts?: InvokeOptions): Promise<GetStackResult>
def get_stack(name: Optional[str] = None, tags: Optional[Mapping[str, str]] = None, opts: Optional[InvokeOptions] = None) -> GetStackResult
func LookupStack(ctx *Context, args *LookupStackArgs, opts ...InvokeOption) (*LookupStackResult, error)

Note: This function is named LookupStack in the Go SDK.

public static class GetStack {
    public static Task<GetStackResult> InvokeAsync(GetStackArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Name string

The name of the stack

Tags Dictionary<string, string>

A map of tags associated with this stack.

Name string

The name of the stack

Tags map[string]string

A map of tags associated with this stack.

name string

The name of the stack

tags {[key: string]: string}

A map of tags associated with this stack.

name str

The name of the stack

tags Mapping[str, str]

A map of tags associated with this stack.

GetStack Result

The following output properties are available:

Capabilities List<string>

A list of capabilities

Description string

Description of the stack

DisableRollback bool

Whether the rollback of the stack is disabled when stack creation fails

IamRoleArn string

The ARN of the IAM role used to create the stack.

Id string

The provider-assigned unique ID for this managed resource.

Name string
NotificationArns List<string>

A list of SNS topic ARNs to publish stack related events

Outputs Dictionary<string, string>

A map of outputs from the stack.

Parameters Dictionary<string, string>

A map of parameters that specify input parameters for the stack.

Tags Dictionary<string, string>

A map of tags associated with this stack.

TemplateBody string

Structure containing the template body.

TimeoutInMinutes int

The amount of time that can pass before the stack status becomes CREATE_FAILED

Capabilities []string

A list of capabilities

Description string

Description of the stack

DisableRollback bool

Whether the rollback of the stack is disabled when stack creation fails

IamRoleArn string

The ARN of the IAM role used to create the stack.

Id string

The provider-assigned unique ID for this managed resource.

Name string
NotificationArns []string

A list of SNS topic ARNs to publish stack related events

Outputs map[string]string

A map of outputs from the stack.

Parameters map[string]string

A map of parameters that specify input parameters for the stack.

Tags map[string]string

A map of tags associated with this stack.

TemplateBody string

Structure containing the template body.

TimeoutInMinutes int

The amount of time that can pass before the stack status becomes CREATE_FAILED

capabilities string[]

A list of capabilities

description string

Description of the stack

disableRollback boolean

Whether the rollback of the stack is disabled when stack creation fails

iamRoleArn string

The ARN of the IAM role used to create the stack.

id string

The provider-assigned unique ID for this managed resource.

name string
notificationArns string[]

A list of SNS topic ARNs to publish stack related events

outputs {[key: string]: string}

A map of outputs from the stack.

parameters {[key: string]: string}

A map of parameters that specify input parameters for the stack.

tags {[key: string]: string}

A map of tags associated with this stack.

templateBody string

Structure containing the template body.

timeoutInMinutes number

The amount of time that can pass before the stack status becomes CREATE_FAILED

capabilities Sequence[str]

A list of capabilities

description str

Description of the stack

disable_rollback bool

Whether the rollback of the stack is disabled when stack creation fails

iam_role_arn str

The ARN of the IAM role used to create the stack.

id str

The provider-assigned unique ID for this managed resource.

name str
notification_arns Sequence[str]

A list of SNS topic ARNs to publish stack related events

outputs Mapping[str, str]

A map of outputs from the stack.

parameters Mapping[str, str]

A map of parameters that specify input parameters for the stack.

tags Mapping[str, str]

A map of tags associated with this stack.

template_body str

Structure containing the template body.

timeout_in_minutes int

The amount of time that can pass before the stack status becomes CREATE_FAILED

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.