Skip to content

Resource: awsCloudformationStack

Provides a CloudFormation Stack resource.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.cloudformationStack.CloudformationStack(this, "network", {
  name: "networking-stack",
  parameters: {
    VPCCidr: "10.0.0.0/16",
  },
  templateBody:
    '${jsonencode({\n    Parameters = {\n      VPCCidr = {\n        Type        = "String"\n        Default     = "10.0.0.0/16"\n        Description = "Enter the CIDR block for the VPC. Default is 10.0.0.0/16."\n      }\n    }\n\n    Resources = {\n      myVpc = {\n        Type = "AWS::EC2::VPC"\n        Properties = {\n          CidrBlock = {\n            "Ref" = "VPCCidr"\n          }\n          Tags = [\n            {\n              Key   = "Name"\n              Value = "Primary_CF_VPC"\n            }\n          ]\n        }\n      }\n    }\n  })}',
});

Argument Reference

The following arguments are supported:

  • name - (Required) Stack name.
  • templateBody - (Optional) Structure containing the template body (max size: 51,200 bytes).
  • templateUrl - (Optional) Location of a file containing the template body (max size: 460,800 bytes).
  • capabilities - (Optional) A list of capabilities. Valid values: CAPABILITY_IAM, CAPABILITY_NAMED_IAM, or CAPABILITY_AUTO_EXPAND
  • disableRollback - (Optional) Set to true to disable rollback of the stack if stack creation failed. Conflicts with onFailure.
  • notificationArns - (Optional) A list of SNS topic ARNs to publish stack related events.
  • onFailure - (Optional) Action to be taken if stack creation fails. This must be one of: DO_NOTHING, rollback, or delete. Conflicts with disableRollback.
  • parameters - (Optional) A map of Parameter structures that specify input parameters for the stack.
  • policyBody - (Optional) Structure containing the stack policy body. Conflicts w/ policyUrl.
  • policyUrl - (Optional) Location of a file containing the stack policy. Conflicts w/ policyBody.
  • tags - (Optional) Map of resource tags to associate with this stack. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
  • iamRoleArn - (Optional) The ARN of an IAM role that AWS CloudFormation assumes to create the stack. If you don't specify a value, AWS CloudFormation uses the role that was previously associated with the stack. If no role is available, AWS CloudFormation uses a temporary session that is generated from your user credentials.
  • timeoutInMinutes - (Optional) The amount of time that can pass before the stack status becomes CREATE_FAILED.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - A unique identifier of the stack.
  • outputs - A map of outputs from the stack.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Timeouts

Configuration options:

  • create - (Default 30M)
  • update - (Default 30M)
  • delete - (Default 30M)

Import

Cloudformation Stacks can be imported using the name, e.g.,

$ terraform import aws_cloudformation_stack.stack networking-stack