-
Notifications
You must be signed in to change notification settings - Fork 1
/
lambda.go
39 lines (34 loc) · 851 Bytes
/
lambda.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
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/awslabs/aws-sdk-go/service/lambda"
"log"
)
func listLambda(region string, verbose bool) (lambdaNumber int) {
var regions = map[string]bool{
"us-east-1": true,
"us-west-2": true,
"eu-west-1": true,
"ap-northeast-1": true,
}
if regions[region] {
svc := lambda.New(session.New(&aws.Config{Region: aws.String(region)}))
params := &lambda.ListFunctionsInput{
MaxItems: aws.Int64(100),
}
resp, err := svc.ListFunctions(params)
if err != nil {
log.Fatal("Cannot get Lambda data: ", err)
}
if verbose {
for _, name := range resp.Functions {
log.Println("Lambda Name: ", *name.FunctionName)
}
}
lambdaNumber = len(resp.Functions)
} else {
lambdaNumber = 0
}
return lambdaNumber
}