> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/provision-infrastructure/cloudformation-infra/remove-provisioned-infra-with-the-cloud-formation-delete-step.md).

# CloudFormation Delete step

Use the CloudFormation Delete Stack step to remove AWS resources provisioned by the CloudFormation Create Stack step. You can delete stacks in the same pipeline or in any pipeline within your Harness project by referencing the same Provisioner Identifier.

***

### What you will learn from this topic <a href="#what-you-will-learn-from-this-topic" id="what-you-will-learn-from-this-topic"></a>

* How to add the [CloudFormation Delete Stack step](#add-the-delete-stack-step) to your pipeline.
* How to configure the step using [Inline](#inline-configuration) or [Inherit from Create](#inherit-from-create-configuration) modes.
* How the [Provisioner Identifier](#provisioner-identifier-scope) links Create and Delete operations across pipelines.

***

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

* **Harness project access**: View and Execute permissions on Pipelines. For more information, refer to [RBAC in Harness](/harness-platform/3.0/harness-platform-resources/platform-access-control/rbac-in-harness.md) to configure roles.
* **AWS connector**: A Harness AWS connector with permissions to delete CloudFormation stacks in your target AWS account. For more information, refer to [AWS connector settings reference](/harness-ai/use-harness-platform/connectors/cloud-providers/ref-cloud-providers/aws-connector-settings-reference.md).
* **Harness Delegate**: A delegate installed in an environment that can connect to AWS. For more information, refer to [Delegate installation overview](/harness-ai/use-harness-platform/delegates/delegate/install-delegates/overview.md).
* **CloudFormation stack created by Harness**: The Delete Stack step removes stacks provisioned by the CloudFormation Create Stack step. For more information, refer to [CloudFormation Create Stack step](/continuous-delivery/use-continuous-delivery/provision-infrastructure/cloudformation-infra/provision-with-the-cloud-formation-create-stack-step.md).

***

### Add the Delete Stack step <a href="#add-the-delete-stack-step" id="add-the-delete-stack-step"></a>

You can use the CloudFormation Delete Stack step to remove stacks provisioned by the CloudFormation Create Stack step or any CloudFormation stacks in your AWS account.

In the **Execution** section of your Deploy stage, click **Add Step**, and then select **CloudFormation Delete Stack**.

***

### Configuration modes <a href="#configuration-modes" id="configuration-modes"></a>

The CloudFormation Delete Stack step supports two configuration modes:

#### Inline configuration <a href="#inline-configuration" id="inline-configuration"></a>

The Inline mode lets you specify the stack details directly in the Delete Stack step. Use this mode to delete any CloudFormation stack in your AWS account, whether or not it was created by Harness.

1. In the **Configuration Type** field, select **Inline**.
2. In **AWS Connector**, select the Harness AWS connector for your target AWS account. The connector credentials must have permissions to delete CloudFormation stacks. For more information, refer to [AWS connector settings reference](/harness-ai/use-harness-platform/connectors/cloud-providers/ref-cloud-providers/aws-connector-settings-reference.md).
3. In **Region**, select the AWS region where the stack exists.
4. In **Role ARN**, enter the AWS IAM Role ARN to use when deleting the stack. This is the same role you would use when deleting a stack using the AWS console or CLI.
5. In **Stack Name**, enter the name of the CloudFormation stack to delete.

<figure><img src="/files/Qz6u5qk3t7Kv85R4phqf" alt="CloudFormation Delete Stack step configuration"><figcaption></figcaption></figure>

<details>

<summary>Inline configuration YAML example</summary>

```yaml
- step:
    type: DeleteStack
    name: Delete CloudFormation Stack
    identifier: Delete_Stack
    spec:
      configuration:
        type: Inline
        spec:
          connectorRef: your_aws_connector
          region: us-east-1
          roleArn: arn:aws:iam::123456789012:role/CloudFormationRole
          stackName: my-cloudformation-stack
      connectorRef: your_aws_connector
    timeout: 10m
```

</details>

#### Inherit from Create configuration <a href="#inherit-from-create-configuration" id="inherit-from-create-configuration"></a>

The Inherit from Create mode deletes the stack that was provisioned by a CloudFormation Create Stack step with the same Provisioner Identifier. Use this mode to tear down infrastructure provisioned earlier in the same pipeline or in a different pipeline within your project.

1. In the **Configuration Type** field, select **Inherit from Create**.
2. In **Provisioner Identifier**, enter the same Provisioner Identifier you used in the CloudFormation Create Stack step that provisioned the stack you want to delete.

Harness determines what to delete using a combination of `Provisioner Identifier + Harness account ID + Harness org ID + Harness project ID`.

<details>

<summary>Inherit from Create configuration YAML example</summary>

```yaml
- step:
    type: DeleteStack
    name: Delete Provisioned Stack
    identifier: DeleteProvisionedStack
    spec:
      provisionerIdentifier: cfn_infrastructure
      configuration:
        type: InheritFromCreate
    timeout: 10m
```

</details>

***

### Provisioner Identifier scope <a href="#provisioner-identifier-scope" id="provisioner-identifier-scope"></a>

The Provisioner Identifier is a project-wide setting. You can reference it across pipelines in the same Harness project.

When using the Inherit from Create mode, all project members must know the Provisioner Identifiers in use. This prevents one team member from accidentally deleting infrastructure provisioned by another team member in a different pipeline.

***

### Next steps <a href="#next-steps" id="next-steps"></a>

* [CloudFormation Rollback Stack step](/continuous-delivery/use-continuous-delivery/provision-infrastructure/cloudformation-infra/rollback-provisioned-infra-with-the-cloud-formation-rollback-step.md): Roll back a stack to its last successfully provisioned version.
* [CloudFormation provisioning](/continuous-delivery/use-continuous-delivery/provision-infrastructure/cloudformation-infra/cloud-formation-provisioning-with-harness.md): Understand CloudFormation provisioning modes and capabilities in Harness.
