AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

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/v5/go/aws/cloudformation"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/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
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var network = Output.of(CloudformationFunctions.getStack(GetStackArgs.builder()
            .name("my-network-stack")
            .build()));

        var web = new Instance("web", InstanceArgs.builder()        
            .ami("ami-abb07bcb")
            .instanceType("t2.micro")
            .subnetId(network.apply(getStackResult -> getStackResult.outputs().SubnetId()))
            .tags(Map.of("Name", "HelloWorld"))
            .build());

    }
}
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",
    },
});
resources:
  web:
    type: aws:ec2:Instance
    properties:
      ami: ami-abb07bcb
      instanceType: t2.micro
      subnetId: ${network.outputs.SubnetId}
      tags:
        Name: HelloWorld
variables:
  network:
    Fn::Invoke:
      Function: aws:cloudformation:getStack
      Arguments:
        name: my-network-stack

Using getStack

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

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

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

public static class GetStack 
{
    public static Task<GetStackResult> InvokeAsync(GetStackArgs args, InvokeOptions? opts = null)
    public static Output<GetStackResult> Invoke(GetStackInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetStackResult> getStack(GetStackArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: aws:cloudformation/getStack:getStack
  Arguments:
    # Arguments dictionary

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 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.

name String

The name of the stack

tags Map<String>

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 List<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 List<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 Integer

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

capabilities List<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 List<String>

A list of SNS topic ARNs to publish stack related events

outputs Map<String>

A map of outputs from the stack.

parameters Map<String>

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

tags Map<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

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.