-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrds.go
43 lines (34 loc) · 980 Bytes
/
rds.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
package main
import (
"strconv"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/rds"
)
func ListRdsInstances(region string) {
conn := rds.New(session.New(), &aws.Config{Region: aws.String(region)})
resp, err := conn.DescribeDBInstances(nil)
if err != nil {
panic(err)
}
table := NewTable([]string{
"ID", "NAME", "ENGINE", "CLASS", "ENDPOINT", "PORT",
})
for _, dbInstance := range resp.DBInstances {
var address string
if nil != dbInstance.Endpoint.Address {
address = stringFromPointer(dbInstance.Endpoint.Address, "")
} else {
address = ""
}
table.Append([]string{
stringFromPointer(dbInstance.DBInstanceIdentifier, ""),
stringFromPointer(dbInstance.DBName, ""),
stringFromPointer(dbInstance.Engine, ""),
stringFromPointer(dbInstance.DBInstanceClass, ""),
address,
strconv.FormatInt(int64FromPointer(dbInstance.Endpoint.Port, 0), 10),
})
}
table.Render()
}