---
title: deletedWith
url: /docs/iac/concepts/resources/options/deletedwith/
---
The `deletedWith` resource option allows you to skip resource deletion if another resource is being deleted as well.

> **Applies to custom and component resources.** The `deletedWith` resource option applies to both [custom resources](/docs/iac/concepts/resources/) and [component resources](/docs/iac/concepts/components/). It is defined on the base resource-options type in every Pulumi SDK.

Pulumi will normally call the provider's delete action for every resource during a delete operation. Sometimes, this is redundant if another resource is also deleted, such as a parent container resource, and can cause your delete or destroy operations to take longer than needed.

For example, if you are deleting a Kubernetes cluster or Kubernetes namespace, you might want to speed up deletion by skipping delete on any Pulumi managed resources created in that Kubernetes cluster or namespace since they will be deleted implicitly.

<!-- chooser: language -->

<!-- option: typescript -->
```typescript
import * as k8s from "@pulumi/kubernetes";

let ns = new k8s.core.v1.Namespace("res1", {/*...*/})
let dep = new k8s.apps.v1.Deployment("res2", {/*...*/}, { deletedWith: ns });

```

<!-- /option -->

<!-- option: python -->
```python
import pulumi_kubernetes as k8s

ns = k8s.core.v1.Namespace("res1", {})
dep = k8s.apps.v1.Deployment("res2", opts=ResourceOptions(deleted_with=ns))

```

<!-- /option -->

<!-- option: go -->
```go
ns, err := v1.NewNamespace(ctx, "res1", nil)
if err != nil {
  return err
}

dep, err := v1.NewDeployment(ctx, "res2", &v1.DeploymentArgs{/*...*/}, pulumi.DeletedWith(ns))
if err != nil {
  return err
}

```

<!-- /option -->

<!-- option: csharp -->
```csharp
var ns = new Namespace("res1");
var dep = new Deployment("res2", new DeploymentArgs(),
    new CustomResourceOptions { DeletedWith = ns });

```

<!-- /option -->

<!-- option: java -->

**Note:** This resource option is not yet implemented for Java. You can follow up the [implementation status on Github](https://github.com/pulumi/pulumi-java/issues/944).

```java
var ns = new Namespace("res1");
var dep = new Deployment("res2", new DeploymentArgs(),
   CustomResourceOptions.builder()
        .deletedWith(ns)
        .build());

```

<!-- /option -->

<!-- option: yaml -->
```yaml
resources:
  ns:
    type: kubernetes:core/v1:Namespace
    name: res1
  res2:
    type: kubernetes:apps/v1:Deployment
    name: res2
    options:
      deletedWith: ${ns}

```

<!-- /option -->

<!-- /chooser -->

## Inheritance from parent

`deletedWith` is inherited from a resource's [`parent`](/docs/iac/concepts/options/parent). Setting `deletedWith` on a parent causes every descendant in the resource tree to skip its provider delete as well, which makes it the idiomatic way to apply `deletedWith` for [component resources](/docs/iac/concepts/components/).

