1. Docs
  2. Concepts
  3. Resource options
  4. deletedWith

Resource option: deletedWith

    The deletedWith resource option allows you to skip resource deletion if a another resource is being deleted as well.

    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 implicitely.

    let k8s = require("@pulumi/kubernetes");
    
    let ns = new k8s.core.v1.Namespace("res1", {/*...*/})
    let dep = new k8s.apps.v1.Deployment("res2", {/*...*/}, { deletedWith: ns });
    
    import * as k8s from "@pulumi/kubernetes";
    
    let ns = new k8s.core.v1.Namespace("res1", {/*...*/})
    let dep = new k8s.apps.v1.Deployment("res2", {/*...*/}, { deletedWith: ns });
    
    # IMPORTANT: Python appends an underscore (`import_`) to avoid conflicting with the keyword.
    
    import pulumi_kubernetes as k8s
    
    ns = k8s.core.v1.Namespace("res1". {})
    dep = k8s.apps.v1.Deployment("res2", opts=ResourceOptions(deleted_with=ns))
    
    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
    }
    
    var ns = new Namespace("res1");
    var dep = new Deployment("res2", new DeploymentArgs(),
        new CustomResourceOptions { DeletedWith = ns });
    
    This resource option is not yet implemented for Java. You can follow up the implementation status on Github.
    var ns = new Namespace("res1");
    var dep = new Deployment("res2", new DeploymentArgs(),
       CustomResourceOptions.builder()
            .deletedWith(ns)
            .build());
    
    resources:
      ns:
        type: kubernetes:apps/v1:Deployment
        name: res1
      res2:
        type: kubernetes:apps/v1:Deployment
        name: res2
        options:
          deletedWith: ${ns}
    
      Introducing Drift Detection, TTL Stacks, and Scheduled Deployments. Learn More.