pulumi/tests/integration/delete_before_create/step5/index.ts
Sean Gillespie 1a51507206
Delete Before Create (#1365)
* Delete Before Create

This commit implements the full semantics of delete before create. If a
resource is replaced and requires deletion before creation, the engine
will use the dependency graph saved in the snapshot to delete all
resources that depend on the resource being replaced prior to the
deletion of the resource to be replaced.

* Rebase against master

* CR: Simplify the control flow in makeRegisterResourceSteps

* Run Check on new inputs when re-creating a resource

* Fix an issue where the planner emitted benign but incorrect deletes of DBR-deleted resources

* CR: produce the list of dependent resources in dependency order and iterate over the list in reverse

* CR: deps->dependents, fix an issue with DependingOn where duplicate nodes could be added to the dependent set

* CR: Fix an issue where we were considering old defaults and new inputs
inappropriately when re-creating a deleted resource

* CR: save 'iter.deletes[urn]' as a local, iterate starting at cursorIndex + 1 for dependency graph
2018-05-23 14:43:17 -07:00

23 lines
894 B
TypeScript

// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
import * as pulumi from "@pulumi/pulumi";
import { Resource } from "./resource";
// The DBR deletion of A triggers the deletion of C due to dependency.
// The planner should execute these steps (in this exact order):
// 1. DeleteReplacement Dependent
// 2. DeleteReplacement Base
// 3. Replace Base
// 4. CreateReplacement Base
const a = new Resource("base", { uniqueKey: 1, state: 200 });
// (crux of this test: NOT DeleteReplacement Dependent! It has already been deleted)
// 5. DeleteReplacement Base-2
// 6. Replace Base-2
// 7. CreateReplacement Base-2
const b = new Resource("base-2", { uniqueKey: 2, state: 50 });
// 8. Replace Dependent
// 9. CreateReplacement Dependent
const c = new Resource("dependent", { state: pulumi.all([a.state, b.state]).apply(([astate, bstate]) => astate + bstate) });