mirror of
https://github.com/adammck/terraform-inventory
synced 2024-11-26 07:43:46 +01:00
Remove aws_instance. prefix from host names
This commit is contained in:
parent
2d1c7fdfd9
commit
d536bd0748
@ -4,6 +4,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type state struct {
|
||||
@ -36,7 +37,8 @@ func (s *state) instances() map[string]instanceState {
|
||||
for _, m := range s.Modules {
|
||||
for k, r := range m.Resources {
|
||||
if r.Type == "aws_instance" {
|
||||
inst[k] = r.Primary
|
||||
name := strings.TrimPrefix(k, "aws_instance.")
|
||||
inst[name] = r.Primary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +111,6 @@ func TestInstances(t *testing.T) {
|
||||
|
||||
inst := s.instances()
|
||||
assert.Equal(t, 2, len(inst))
|
||||
assert.Equal(t, "i-aaaaaaaa", inst["aws_instance.one"].ID)
|
||||
assert.Equal(t, "i-bbbbbbbb", inst["aws_instance.two"].ID)
|
||||
assert.Equal(t, "i-aaaaaaaa", inst["one"].ID)
|
||||
assert.Equal(t, "i-bbbbbbbb", inst["two"].ID)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user