From 9707eb3fc8ad8f7de38a0fef5c0beb76b2441f67 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Fri, 21 Nov 2014 15:34:23 -0800 Subject: [PATCH] terraform: Add dependencies field to modules --- terraform/state.go | 14 ++++++++++++++ terraform/state_test.go | 3 +++ 2 files changed, 17 insertions(+) diff --git a/terraform/state.go b/terraform/state.go index f13ecf109..529f33983 100644 --- a/terraform/state.go +++ b/terraform/state.go @@ -185,6 +185,20 @@ type ModuleState struct { // N instances underneath, although a user only needs to think // about the 1:1 case. Resources map[string]*ResourceState `json:"resources"` + + // Dependencies are a list of things that this module relies on + // existing to remain intact. For example: an module may depend + // on a VPC ID given by an aws_vpc resource. + // + // Terraform uses this information to build valid destruction + // orders and to warn the user if they're destroying a module that + // another resource depends on. + // + // Things can be put into this list that may not be managed by + // Terraform. If Terraform doesn't find a matching ID in the + // overall state, then it assumes it isn't managed and doesn't + // worry about it. + Dependencies []string `json:"depends_on,omitempty"` } // IsRoot says whether or not this module diff is for the root module. diff --git a/terraform/state_test.go b/terraform/state_test.go index 9ee251745..57e1308c1 100644 --- a/terraform/state_test.go +++ b/terraform/state_test.go @@ -180,6 +180,9 @@ func TestReadWriteState(t *testing.T) { Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, + Dependencies: []string{ + "aws_instance.bar", + }, Resources: map[string]*ResourceState{ "foo": &ResourceState{ Primary: &InstanceState{