4 "github.com/hashicorp/terraform/config/module"
5 "github.com/hashicorp/terraform/dag"
8 // DestroyPlanGraphBuilder implements GraphBuilder and is responsible for
9 // planning a pure-destroy.
11 // Planning a pure destroy operation is simple because we can ignore most
12 // ordering configuration and simply reverse the state.
13 type DestroyPlanGraphBuilder struct {
14 // Module is the root module for the graph to build.
17 // State is the current state
20 // Targets are resources to target
23 // Validate will do structural validation of the graph.
28 func (b *DestroyPlanGraphBuilder) Build(path []string) (*Graph, error) {
29 return (&BasicGraphBuilder{
32 Name: "DestroyPlanGraphBuilder",
37 func (b *DestroyPlanGraphBuilder) Steps() []GraphTransformer {
38 concreteResource := func(a *NodeAbstractResource) dag.Vertex {
39 return &NodePlanDestroyableResource{
40 NodeAbstractResource: a,
44 steps := []GraphTransformer{
45 // Creates all the nodes represented in the state.
47 Concrete: concreteResource,
51 // Attach the configuration to any resources
52 &AttachResourceConfigTransformer{Module: b.Module},
54 // Destruction ordering. We require this only so that
55 // targeting below will prune the correct things.
56 &DestroyEdgeTransformer{Module: b.Module, State: b.State},
58 // Target. Note we don't set "Destroy: true" here since we already
59 // created proper destroy ordering.
60 &TargetsTransformer{Targets: b.Targets},