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:
- Set
protect: false
and then runpulumi up
- Use the
pulumi state unprotect
command
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
Thank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.