terraform: ResourceAddress should output instance type if set

This commit is contained in:
Mitchell Hashimoto 2016-04-11 17:03:25 -07:00
parent 4faa6b37e4
commit 407be65cc8
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 10 additions and 6 deletions

View File

@ -52,12 +52,16 @@ func (r *ResourceAddress) String() string {
if r.Name != "" { if r.Name != "" {
name := r.Name name := r.Name
if r.InstanceTypeSet {
switch r.InstanceType { switch r.InstanceType {
case TypePrimary:
name += ".primary"
case TypeDeposed: case TypeDeposed:
name += ".deposed" name += ".deposed"
case TypeTainted: case TypeTainted:
name += ".tainted" name += ".tainted"
} }
}
if r.Index >= 0 { if r.Index >= 0 {
name += fmt.Sprintf("[%d]", r.Index) name += fmt.Sprintf("[%d]", r.Index)

View File

@ -50,7 +50,7 @@ func TestParseResourceAddress(t *testing.T) {
InstanceTypeSet: true, InstanceTypeSet: true,
Index: 2, Index: 2,
}, },
"aws_instance.foo[2]", "",
}, },
"tainted": { "tainted": {
"aws_instance.foo.tainted", "aws_instance.foo.tainted",