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{