| 23 | } |
| 24 | |
| 25 | func handleRequest(ctx context.Context, event events.SQSEvent) (string, error) { |
| 26 | // event |
| 27 | eventJson, _ := json.MarshalIndent(event, "", " ") |
| 28 | log.Printf("EVENT: %s", eventJson) |
| 29 | // environment variables |
| 30 | log.Printf("REGION: %s", os.Getenv("AWS_REGION")) |
| 31 | log.Println("ALL ENV VARS:") |
| 32 | for _, element := range os.Environ() { |
| 33 | log.Println(element) |
| 34 | } |
| 35 | // request context |
| 36 | lc, _ := lambdacontext.FromContext(ctx) |
| 37 | log.Printf("REQUEST ID: %s", lc.AwsRequestID) |
| 38 | // global variable |
| 39 | log.Printf("FUNCTION NAME: %s", lambdacontext.FunctionName) |
| 40 | // context method |
| 41 | deadline, _ := ctx.Deadline() |
| 42 | log.Printf("DEADLINE: %s", deadline) |
| 43 | // AWS SDK call |
| 44 | usage, err := callLambda() |
| 45 | if err != nil { |
| 46 | return "ERROR", err |
| 47 | } |
| 48 | return usage, nil |
| 49 | } |
| 50 | |
| 51 | func main() { |
| 52 | runtime.Start(handleRequest) |