1
1
mirror of https://github.com/adammck/terraform-inventory synced 2024-11-22 20:01:58 +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)

@ -19,8 +19,8 @@ var keyNames []string
func init() {
keyNames = []string{
"ipv4_address", // DO
"public_ip", // AWS
"private_ip", // AWS
"public_ip", // AWS
"private_ip", // AWS
}
}
@ -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
}