-
Notifications
You must be signed in to change notification settings - Fork 8
/
vars.go
41 lines (35 loc) · 832 Bytes
/
vars.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
package cliaws
import (
"context"
"fmt"
"github.com/alexflint/go-arg"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/nathants/libaws/lib"
)
func init() {
lib.Commands["lambda-vars"] = lambdaVars
lib.Args["lambda-vars"] = lambdaVarsArgs{}
}
type lambdaVarsArgs struct {
Name string `arg:"positional"`
}
func (lambdaVarsArgs) Description() string {
return "\nget lambda vars\n"
}
func lambdaVars() {
var args lambdaVarsArgs
arg.MustParse(&args)
ctx := context.Background()
out, err := lib.LambdaClient().GetFunctionWithContext(ctx, &lambda.GetFunctionInput{
FunctionName: aws.String(args.Name),
})
if err != nil {
lib.Logger.Fatal("error: ", err)
}
for k, v := range out.Configuration.Environment.Variables {
if v != nil {
fmt.Printf("%s=%s\n", k, *v)
}
}
}