generated from GSA/grace-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
67 lines (59 loc) · 1.24 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"fmt"
"time"
"github.com/GSA/grace-inventory/handler/inv"
"github.com/GSA/grace-inventory/handler/spreadsheet"
"github.com/aws/aws-lambda-go/lambda"
)
func createReport() (string, error) {
filename := fmt.Sprintf("grace_inventory_%s.xlsx", time.Now().Format("2006-01-02-1504"))
inventory, err := inv.New()
if err != nil {
return err.Error(), err
}
s := spreadsheet.New(filename)
sheets := []string{
inv.SheetAccounts,
inv.SheetBuckets,
inv.SheetGroups,
inv.SheetImages,
inv.SheetInstances,
inv.SheetPolicies,
inv.SheetRoles,
inv.SheetSecurityGroups,
inv.SheetSnapshots,
inv.SheetSubnets,
inv.SheetUsers,
inv.SheetVolumes,
inv.SheetVpcs,
inv.SheetAddresses,
inv.SheetKeyPairs,
inv.SheetStacks,
inv.SheetAlarms,
inv.SheetConfigRules,
inv.SheetLoadBalancers,
inv.SheetVaults,
inv.SheetKeys,
inv.SheetDBInstances,
inv.SheetDBSnapshots,
inv.SheetSecrets,
inv.SheetSubscriptions,
inv.SheetTopics,
inv.SheetParameters,
}
for _, sheet := range sheets {
err = s.AddSheet(sheet)
if err != nil {
return err.Error(), err
}
}
err = inventory.Run(s)
if err != nil {
return err.Error(), err
}
return "Report Complete", nil
}
func main() {
lambda.Start(createReport)
}