DeleteBeforeReplace

A resource may need to be replaced if an immutable property changes. In these cases, cloud providers do not support updating an existing resource so a new instance will be created and the old one deleted. By default, to minimize downtime, Pulumi creates new instances of resources before deleting old ones.

Setting the deleteBeforeReplace option to true means that Pulumi will delete the existing resource before creating its replacement. Be aware that this behavior has a cascading impact on dependencies so more resources may be replaced, which can lead to downtime. However, this option may be necessary for some resources that manage scarce resources behind the scenes, and/or resources that cannot exist side-by-side.

This example deletes a database entirely before its replacement is created:

let db = new Database("db", {/*...*/},
    { deleteBeforeReplace: true});
let db = new Database("db", {/*...*/},
    { deleteBeforeReplace: true});
db = Database("db",
    opts=ResourceOptions(delete_before_replace=True))
db, err := NewDatabase(ctx, "db", &DatabaseArgs{ /*...*/ },
    pulumi.DeleteBeforeReplace(true))
// The resource will be deleted before it's replacement is created
var db = new Database("db", new DatabaseArgs(),
    new CustomResourceOptions { DeleteBeforeReplace = true });
// The resource will be deleted before it's replacement is created
var db = new Database("db",
    DatabaseArgs.Empty,
    CustomResourceOptions.builder()
        .deleteBeforeReplace(true)
        .build());
# The resource will be deleted before it's replacement is created
resources:
  db:
    type: Database
    options:
      deleteBeforeReplace: true