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",