From 3480b7ebee37f75929fad281d7cfe3a9173b4515 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 30 Apr 2016 17:52:39 -0500 Subject: [PATCH] terraform: state filter wasn't comparing resource names --- terraform/state_filter.go | 4 ++++ terraform/state_filter_test.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/terraform/state_filter.go b/terraform/state_filter.go index 74fe501c1..43cca6bc9 100644 --- a/terraform/state_filter.go +++ b/terraform/state_filter.go @@ -99,6 +99,10 @@ func (f *StateFilter) filterSingle(a *ResourceAddress) []*StateFilterResult { continue } + if a.Name != "" && a.Name != key.Name { + continue + } + // Build the address for this resource addr := &ResourceAddress{ Path: m.Path[1:], diff --git a/terraform/state_filter_test.go b/terraform/state_filter_test.go index d9b1db8d5..f9187b4e9 100644 --- a/terraform/state_filter_test.go +++ b/terraform/state_filter_test.go @@ -69,6 +69,12 @@ func TestStateFilterFilter(t *testing.T) { }, }, + "resource in module 2": { + "resource-in-module-2.tfstate", + []string{"module.foo.aws_instance.foo"}, + []string{}, + }, + "single count index": { "complete.tfstate", []string{"module.consul.aws_instance.consul-green[0]"},