1. Docs
  2. Pulumi IaC
  3. Concepts
  4. Resource options
  5. 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});
Copy
let db = new Database("db", {}, { protect: true});
Copy
db = Database("db", opts=ResourceOptions(protect=True))
Copy
db, _ := NewDatabase(ctx, "db", &DatabaseArgs{}, pulumi.Protect(true));
Copy
var db = new Database("db", new DatabaseArgs(),
    new CustomResourceOptions { Protect = true });
Copy
var db = new Database("db",
    DatabaseArgs.Empty,
    CustomResourceOptions.builder()
        .protect(true)
        .build());
Copy
resources:
  type: Database
  options:
    protect: true
Copy

Was this page helpful?

PulumiUP May 6, 2025. Register Now.