-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLambda.swift
39 lines (34 loc) · 1.37 KB
/
Lambda.swift
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
// ===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftAWSLambdaRuntime open source project
//
// Copyright (c) 2021 Apple Inc. and the SwiftAWSLambdaRuntime project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
//
// SPDX-License-Identifier: Apache-2.0
//
// ===----------------------------------------------------------------------===//
import AWSLambdaEvents
import AWSLambdaRuntime
import Foundation
@main
struct SQSLambda: LambdaHandler {
typealias Event = SQSEvent
typealias Output = Void
init() {}
init(context: LambdaInitializationContext) async throws {
context.logger.info(
"Log Level env var : \(ProcessInfo.processInfo.environment["LOG_LEVEL"] ?? "info")")
}
func handle(_ event: Event, context: AWSLambdaRuntimeCore.LambdaContext) async throws -> Output {
context.logger.info("Log Level env var : \(ProcessInfo.processInfo.environment["LOG_LEVEL"] ?? "not defined")")
context.logger.debug("SQS Message received, with \(event.records.count) record")
for msg in event.records {
context.logger.debug("Message ID : \(msg.messageId)")
context.logger.debug("Message body : \(msg.body)")
}
}
}