From f398708be21ec7423cc2d72f59a05b2f65a6fd59 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 22 Sep 2014 16:15:15 -0700 Subject: [PATCH] terraform: Adding flag for CreateBeforeDestroy --- terraform/graph.go | 3 +++ terraform/graph_test.go | 6 ++++++ terraform/resource.go | 1 + 3 files changed, 10 insertions(+) diff --git a/terraform/graph.go b/terraform/graph.go index f375b1f4bb..9e766d4233 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -557,6 +557,9 @@ func graphAddDiff(g *depgraph.Graph, d *ModuleDiff) error { Target: newN, }) + // Set the CreateBeforeDestroy flag on the old noun + rn.Resource.Flags |= FlagCreateBeforeDestroy + } else { dep := &depgraph.Dependency{ Name: newN.Name, diff --git a/terraform/graph_test.go b/terraform/graph_test.go index 710fb3417f..d52b3ea18f 100644 --- a/terraform/graph_test.go +++ b/terraform/graph_test.go @@ -704,6 +704,12 @@ func TestGraphAddDiff_createBeforeDestroy(t *testing.T) { t.Fatalf("bad:\n\n%s\n\nexpected:\n\n%s", actual, expected) } + // Verify the flag is set + r := g.Noun("aws_instance.bar") + if r.Meta.(*GraphNodeResource).Resource.Flags&FlagCreateBeforeDestroy == 0 { + t.Fatalf("missing FlagCreateBeforeDestroy") + } + // Verify that our original structure has not been modified diffHash2 := checksumStruct(t, diff) if diffHash != diffHash2 { diff --git a/terraform/resource.go b/terraform/resource.go index 0df27524a3..cd1e86bb11 100644 --- a/terraform/resource.go +++ b/terraform/resource.go @@ -47,6 +47,7 @@ const ( FlagTainted FlagOrphan FlagHasTainted + FlagCreateBeforeDestroy ) // InstanceInfo is used to hold information about the instance and/or