-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
list.go
44 lines (40 loc) · 998 Bytes
/
list.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
package lambroll
import (
"context"
"fmt"
"log"
"os"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/lambda"
)
// ListOption represents options for List()
type ListOption struct {
}
// List lists lambda functions
func (app *App) List(ctx context.Context, opt *ListOption) error {
var marker *string
for {
res, err := app.lambda.ListFunctions(ctx, &lambda.ListFunctionsInput{
MaxItems: aws.Int32(50),
})
if err != nil {
return fmt.Errorf("failed to ListFunctions: %w", err)
}
for _, c := range res.Functions {
arn := app.functionArn(ctx, *c.FunctionName)
log.Printf("[debug] listing tags of %s", arn)
res, err := app.lambda.ListTags(ctx, &lambda.ListTagsInput{
Resource: aws.String(arn),
})
if err != nil {
return fmt.Errorf("failed to list tags: %w", err)
}
b, _ := marshalJSON(newFunctionFrom(&c, nil, res.Tags))
os.Stdout.Write(b)
}
if marker = res.NextMarker; marker == nil {
break
}
}
return nil
}