/
main.go
46 lines (38 loc) · 821 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"flag"
"fmt"
"os"
"sync"
"github.com/belminf/yadig/aws"
"github.com/belminf/yadig/config"
)
// Collect flags
func init() {
}
// Collect ENIs
func getMatchedEnis(sess *aws.ProfileSessionType, ip string, prAlias string, wg *sync.WaitGroup) {
defer wg.Done()
for _, i := range aws.InterfacesWithIP(sess, ip) {
fmt.Printf("[%s] %s\n", prAlias, i.Display)
}
}
func main() {
flag.Parse()
ip := flag.Arg(0)
yadigConfig := config.LoadConfig(aws.ConfigIniPath)
if ip == "" {
fmt.Println("[ERROR] Provided no IP")
os.Exit(1)
}
// Collect results
wg := sync.WaitGroup{}
fmt.Println("")
for _, pr := range yadigConfig.ProfileRegions {
sess := aws.ProfileSession(pr.Profile, pr.Region)
wg.Add(1)
go getMatchedEnis(sess, ip, pr.Alias(), &wg)
}
wg.Wait()
fmt.Println("")
}