-
Notifications
You must be signed in to change notification settings - Fork 9
/
lambda.go
37 lines (31 loc) · 820 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
package helpers
import (
"github.com/aws/aws-sdk-go/service/lambda"
)
// GetAllLambdaInRegion List all lambdas in a region
func GetAllLambdaInRegion(region string, arn string) []*lambda.FunctionConfiguration {
awsSession, _ := InitAwsSession(region)
svc := lambda.New(awsSession)
input := &lambda.ListFunctionsInput{}
result, _ := svc.ListFunctions(input)
lambdas := result.Functions
// Iterate over NextMarker
for result.NextMarker != nil {
input = &lambda.ListFunctionsInput{
Marker: result.NextMarker,
}
result, _ = svc.ListFunctions(input)
lambdas = append(lambdas, result.Functions...)
}
// Filter out lambda
if len(arn) > 0 {
for _, l := range lambdas {
if *l.FunctionArn == arn {
lambdas = nil
lambdas = append(lambdas, l)
return lambdas
}
}
}
return lambdas
}