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

Resource option: protect

    The protect resource option marks a resource as protected. A protected resource cannot be deleted directly, and it will be an error to do a Pulumi deployment which tries to delete a protected resource for any reason.

    To delete a protected resource, it must first be unprotected. There are two ways to unprotect a resource:

    Once the resource is unprotected, it can be deleted as part of a following update.

    The default is to inherit this value from the parent resource, and false for resources without a parent.

    let db = new Database("db", {}, { protect: true});
    
    let db = new Database("db", {}, { protect: true});
    
    db = Database("db", opts=ResourceOptions(protect=True))
    
    db, _ := NewDatabase(ctx, "db", &DatabaseArgs{}, pulumi.Protect(true));
    
    var db = new Database("db", new DatabaseArgs(),
        new CustomResourceOptions { Protect = true });
    
    var db = new Database("db",
        DatabaseArgs.Empty,
        CustomResourceOptions.builder()
            .protect(true)
            .build());
    
    resources:
      type: Database
      options:
        protect: true
    
      Pulumi AI - What cloud infrastructure would you like to build? Generate Program