1
1
mirror of https://github.com/adammck/terraform-inventory synced 2024-11-23 00:12:13 +01:00

Also check for terraform.tfstate in pwd

This commit is contained in:
Adam Mckaig 2015-06-05 00:22:08 -04:00
parent 47c0c9f64c
commit dbe88863eb
2 changed files with 12 additions and 3 deletions

@ -30,6 +30,15 @@ func main() {
file = os.Getenv("TI_TFSTATE")
}
// check for a file named terraform.tfstate in the pwd
if file == "" {
fn := "terraform.tfstate"
_, err := os.Stat(fn)
if err == nil {
file = fn
}
}
if file == "" {
fmt.Printf("Usage: %s [options] path\n", os.Args[0])
os.Exit(1)

@ -76,7 +76,7 @@ func (s resourceState) isSupported() bool {
// Address returns the IP address of this resource.
func (s resourceState) Address() string {
for _, key := range(keyNames) {
for _, key := range keyNames {
if ip := s.Primary.Attributes[key]; ip != "" {
return ip
}