> ## Documentation Index
> Fetch the complete documentation index at: https://docs.controlplane.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Resources from Manifests

> Remove Control Plane resources using the same YAML/JSON files used to create them.

The `cpln delete` command removes resources defined in YAML or JSON files, the inverse of `cpln apply`. Use the same manifest files to both create and tear down infrastructure.

## When to use this

<CardGroup cols={2}>
  <Card title="Tear down environments" icon="trash">
    Remove entire environments using the same manifests that created them
  </Card>

  <Card title="GitOps cleanup" icon="code-branch">
    Delete resources tracked in version control
  </Card>

  <Card title="Remove K8s conversions" icon="right-left">
    Delete resources originally created from Kubernetes manifests
  </Card>

  <Card title="Batch deletion" icon="layer-group">
    Remove multiple related resources in one command
  </Card>
</CardGroup>

## Basic usage

```bash theme={null}
cpln delete --file <manifest.yaml>
```

This deletes all resources defined in the file.

## Options

| Option   | Description                                                  |
| -------- | ------------------------------------------------------------ |
| `--file` | Path to JSON/YAML file. Use `--file -` for stdin             |
| `--gvc`  | GVC for scoped resources (workloads, identities, volumesets) |
| `--k8s`  | Convert K8s manifest before deleting (`true`/`false`)        |

## Specify the GVC

Workloads, identities, and volumesets are scoped to a GVC. Specify it using one of these methods:

<Tabs>
  <Tab title="--gvc flag">
    Pass the GVC with each command:

    ```bash theme={null}
    cpln delete --file workload.yaml --gvc my-gvc
    ```
  </Tab>

  <Tab title="In the manifest">
    Include the GVC in the resource definition:

    ```yaml workload.yaml theme={null}
    kind: workload
    name: my-app
    gvc: my-gvc
    spec:
      type: serverless
      containers:
        - name: main
          image: nginx:latest
    ```

    ```bash theme={null}
    cpln delete --file workload.yaml
    ```
  </Tab>

  <Tab title="Profile default">
    Set a default GVC in your profile:

    ```bash theme={null}
    cpln profile update default --gvc my-gvc
    cpln delete --file workload.yaml
    ```
  </Tab>
</Tabs>

<Note>
  You can either specify the GVC in the manifest or via `--gvc`, but not both.
</Note>

## Delete Kubernetes conversions

Delete resources that were originally applied from Kubernetes manifests:

```bash theme={null}
cpln delete --file k8s-deployment.yaml --k8s true
```

This converts the K8s manifest to Control Plane format, then deletes the corresponding resources.

## Delete from stdin

Pipe resources from another command:

```bash theme={null}
# Delete resources from a converted K8s manifest
cpln convert --file k8s.yaml | cpln delete --file -

# Delete resources from a remote file
curl -s https://example.com/resources.yaml | cpln delete --file -
```

## Multiple resources

Delete multiple resources from a single file using YAML document separators (`---`):

```yaml resources.yaml theme={null}
kind: workload
name: my-app
gvc: production
spec:
  type: serverless
  containers:
    - name: main
      image: nginx:latest
---
kind: identity
name: my-identity
gvc: production
---
kind: secret
name: my-secret
type: opaque
```

```bash theme={null}
cpln delete --file resources.yaml
```

## Using the console

Delete resources via the console:

1. Click **cpln apply** in the upper right corner
2. Enable the **Use as Delete** switch
3. Upload or paste your manifest
4. Select the target org and GVC
5. Click **Delete**

## Common workflows

### Tear down a complete environment

```bash theme={null}
# Delete all resources in an environment manifest
cpln delete --file production-env.yaml
```

### Remove a feature branch environment

```bash theme={null}
# Clean up after merging
cpln delete --file feature-branch.yaml --gvc feature-123
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Resource not found">
    The resource may have already been deleted or never existed. This is not an error - the command is idempotent.
  </Accordion>

  <Accordion title="GVC required">
    For workloads, identities, and volumesets, specify the GVC:

    ```bash theme={null}
    cpln delete --file workload.yaml --gvc my-gvc
    ```
  </Accordion>

  <Accordion title="Dependency errors">
    Some resources can't be deleted if other resources depend on them. Delete dependent resources first, or delete the GVC containing all resources.
  </Accordion>
</AccordionGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Apply YAML Manifests" href="/guides/cpln-apply" icon="file-code">
    Create resources from manifests
  </Card>

  <Card title="Convert K8s Manifests" href="/guides/cli/cpln-convert" icon="right-left">
    Convert Kubernetes resources
  </Card>

  <Card title="Command Reference" href="/cli-reference/commands/delete" icon="book">
    Full delete command reference
  </Card>

  <Card title="CI/CD Usage" href="/cli-reference/ci-cd-development/ci-cd" icon="code">
    Automate deletions in pipelines
  </Card>
</CardGroup>
