1. Packages
  2. AWS Classic
  3. API Docs
  4. cloudformation
  5. getStack

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.27.0 published on Monday, Mar 18, 2024 by Pulumi

aws.cloudformation.getStack

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.27.0 published on Monday, Mar 18, 2024 by Pulumi

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

    Example Usage

    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",
        },
    });
    
    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",
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudformation"
    	"github.com/pulumi/pulumi-aws/sdk/v6/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
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var network = Aws.CloudFormation.GetStack.Invoke(new()
        {
            Name = "my-network-stack",
        });
    
        var web = new Aws.Ec2.Instance("web", new()
        {
            Ami = "ami-abb07bcb",
            InstanceType = "t2.micro",
            SubnetId = network.Apply(getStackResult => getStackResult.Outputs?.SubnetId),
            Tags = 
            {
                { "Name", "HelloWorld" },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.cloudformation.CloudformationFunctions;
    import com.pulumi.aws.cloudformation.inputs.GetStackArgs;
    import com.pulumi.aws.ec2.Instance;
    import com.pulumi.aws.ec2.InstanceArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var network = CloudformationFunctions.getStack(GetStackArgs.builder()
                .name("my-network-stack")
                .build());
    
            var web = new Instance("web", InstanceArgs.builder()        
                .ami("ami-abb07bcb")
                .instanceType("t2.micro")
                .subnetId(network.applyValue(getStackResult -> getStackResult.outputs().SubnetId()))
                .tags(Map.of("Name", "HelloWorld"))
                .build());
    
        }
    }
    
    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
    Name of the stack
    Tags Dictionary<string, string>
    Map of tags associated with this stack.
    Name string
    Name of the stack
    Tags map[string]string
    Map of tags associated with this stack.
    name String
    Name of the stack
    tags Map<String,String>
    Map of tags associated with this stack.
    name string
    Name of the stack
    tags {[key: string]: string}
    Map of tags associated with this stack.
    name str
    Name of the stack
    tags Mapping[str, str]
    Map of tags associated with this stack.
    name String
    Name of the stack
    tags Map<String>
    Map of tags associated with this stack.

    getStack Result

    The following output properties are available:

    Capabilities List<string>
    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
    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>
    List of SNS topic ARNs to publish stack related events
    Outputs Dictionary<string, string>
    Map of outputs from the stack.
    Parameters Dictionary<string, string>
    Map of parameters that specify input parameters for the stack.
    Tags Dictionary<string, string>
    Map of tags associated with this stack.
    TemplateBody string
    Structure containing the template body.
    TimeoutInMinutes int
    Amount of time that can pass before the stack status becomes CREATE_FAILED
    Capabilities []string
    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
    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
    List of SNS topic ARNs to publish stack related events
    Outputs map[string]string
    Map of outputs from the stack.
    Parameters map[string]string
    Map of parameters that specify input parameters for the stack.
    Tags map[string]string
    Map of tags associated with this stack.
    TemplateBody string
    Structure containing the template body.
    TimeoutInMinutes int
    Amount of time that can pass before the stack status becomes CREATE_FAILED
    capabilities List<String>
    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
    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>
    List of SNS topic ARNs to publish stack related events
    outputs Map<String,String>
    Map of outputs from the stack.
    parameters Map<String,String>
    Map of parameters that specify input parameters for the stack.
    tags Map<String,String>
    Map of tags associated with this stack.
    templateBody String
    Structure containing the template body.
    timeoutInMinutes Integer
    Amount of time that can pass before the stack status becomes CREATE_FAILED
    capabilities string[]
    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
    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[]
    List of SNS topic ARNs to publish stack related events
    outputs {[key: string]: string}
    Map of outputs from the stack.
    parameters {[key: string]: string}
    Map of parameters that specify input parameters for the stack.
    tags {[key: string]: string}
    Map of tags associated with this stack.
    templateBody string
    Structure containing the template body.
    timeoutInMinutes number
    Amount of time that can pass before the stack status becomes CREATE_FAILED
    capabilities Sequence[str]
    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
    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]
    List of SNS topic ARNs to publish stack related events
    outputs Mapping[str, str]
    Map of outputs from the stack.
    parameters Mapping[str, str]
    Map of parameters that specify input parameters for the stack.
    tags Mapping[str, str]
    Map of tags associated with this stack.
    template_body str
    Structure containing the template body.
    timeout_in_minutes int
    Amount of time that can pass before the stack status becomes CREATE_FAILED
    capabilities List<String>
    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
    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>
    List of SNS topic ARNs to publish stack related events
    outputs Map<String>
    Map of outputs from the stack.
    parameters Map<String>
    Map of parameters that specify input parameters for the stack.
    tags Map<String>
    Map of tags associated with this stack.
    templateBody String
    Structure containing the template body.
    timeoutInMinutes Number
    Amount of time that can pass before the stack status becomes CREATE_FAILED

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.27.0 published on Monday, Mar 18, 2024 by Pulumi