2.1 KiB
title_tag, meta_desc, title, h1, meta_image, menu, aliases
title_tag | meta_desc | title | h1 | meta_image | menu | aliases | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
protect | Resource Options | The protect resource option prevents accidental deletion of a resource by marking it as protected. | protect | Resource option: protect | /images/docs/meta-images/docs-meta.png |
|
|
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.
{{< chooser language "javascript,typescript,python,go,csharp,java,yaml" >}}
{{% choosable language javascript %}}
let db = new Database("db", {}, { protect: true});
{{% /choosable %}} {{% choosable language typescript %}}
let db = new Database("db", {}, { protect: true});
{{% /choosable %}} {{% choosable language python %}}
db = Database("db", opts=ResourceOptions(protect=True))
{{% /choosable %}} {{% choosable language go %}}
db, _ := NewDatabase(ctx, "db", &DatabaseArgs{}, pulumi.Protect(true));
{{% /choosable %}} {{% choosable language csharp %}}
var db = new Database("db", new DatabaseArgs(),
new CustomResourceOptions { Protect = true });
{{% /choosable %}} {{% choosable language java %}}
var db = new Database("db",
DatabaseArgs.Empty,
CustomResourceOptions.builder()
.protect(true)
.build());
{{% /choosable %}} {{% choosable language yaml %}}
resources:
type: Database
options:
protect: true
{{% /choosable %}}
{{< /chooser >}}