From 407be65cc8e520415744ceaa8a0181018199130b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 11 Apr 2016 17:03:25 -0700 Subject: [PATCH] terraform: ResourceAddress should output instance type if set --- terraform/resource_address.go | 14 +++++++++----- terraform/resource_address_test.go | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/terraform/resource_address.go b/terraform/resource_address.go index d6bb0522e..90f0eafd3 100644 --- a/terraform/resource_address.go +++ b/terraform/resource_address.go @@ -52,11 +52,15 @@ func (r *ResourceAddress) String() string { if r.Name != "" { name := r.Name - switch r.InstanceType { - case TypeDeposed: - name += ".deposed" - case TypeTainted: - name += ".tainted" + if r.InstanceTypeSet { + switch r.InstanceType { + case TypePrimary: + name += ".primary" + case TypeDeposed: + name += ".deposed" + case TypeTainted: + name += ".tainted" + } } if r.Index >= 0 { diff --git a/terraform/resource_address_test.go b/terraform/resource_address_test.go index 193c56c44..17dc92367 100644 --- a/terraform/resource_address_test.go +++ b/terraform/resource_address_test.go @@ -50,7 +50,7 @@ func TestParseResourceAddress(t *testing.T) { InstanceTypeSet: true, Index: 2, }, - "aws_instance.foo[2]", + "", }, "tainted": { "aws_instance.foo.tainted",