Skip to content

Commit

Permalink
Increase Lambda timeout & memory + fix logging (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhz authored Sep 7, 2023
1 parent 64a21b1 commit 1e341a7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
39 changes: 19 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@ ThisBuild / scalaVersion := "2.13.11"

lazy val root = (project in file("."))
.settings(
name := "da-reference-generator"
name := "da-reference-generator",
libraryDependencies ++= Seq(
awsSdkDynamoDbV2,
awsSdkDynamoDbV1 % Test,
lambdaJavaCore,
lambdaJavaEvents,
scalaTest % Test,
ocitools,
circeCore,
circeGeneric,
circeParser,
scalaLogging,
logback,
logstash,
typesafe,
testContainer % Test,
testContainerDynalite % Test
)
)

libraryDependencies ++= Seq(
awsSdkDynamoDbV2,
awsSdkDynamoDbV1 % Test,
lambdaJavaCore,
lambdaJavaEvents,
scalaTest % Test,
ocitools,
circeCore,
circeGeneric,
circeParser,
scalaLogging,
logback,
logstash,
typesafe,
testContainer % Test,
testContainerDynalite % Test
)

(assembly / assemblyJarName) := "reference-generator.jar"

(assembly / assemblyMergeStrategy) := {
case PathList("META-INF", xs @_*) => MergeStrategy.discard
case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard
case _ => MergeStrategy.first
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import com.typesafe.scalalogging.Logger
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.dynamodb.DynamoDbClient
import uk.gov.nationalarchives.referencegenerator.Lambda.{Input, Reference, config, counterClient}
import uk.gov.nationalarchives.referencegenerator.Lambda.{Input, Reference, config, counterClient, logger}
import io.circe.syntax._
import software.amazon.awssdk.http.SdkHttpClient
import software.amazon.awssdk.http.apache.ApacheHttpClient

import scala.util.{Failure, Success, Try}

class Lambda extends RequestHandler[APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent] {
val logger: Logger = Logger[Lambda]

override def handleRequest(event: APIGatewayProxyRequestEvent, context: Context): APIGatewayProxyResponseEvent = {
val queryParams = event.getQueryStringParameters
Expand Down Expand Up @@ -57,7 +56,7 @@ class Lambda extends RequestHandler[APIGatewayProxyRequestEvent, APIGatewayProxy
}

object Lambda {

val logger: Logger = Logger[Lambda]
val sdkHttpClient: SdkHttpClient = ApacheHttpClient.builder().build()
val counterClient: DynamoDbClient = DynamoDbClient.builder()
.credentialsProvider(DefaultCredentialsProvider.create())
Expand Down
6 changes: 4 additions & 2 deletions terraform/root_main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ module "reference_generator_lambda" {
REFERENCE_COUNTER = "referenceCounter"
QUERY_PARAM = "numberofrefs"
}
runtime = "java11"
tags = local.hosting_common_tags
runtime = "java11"
timeout_seconds = 60
memory_size = 1024
tags = local.hosting_common_tags
}

0 comments on commit 1e341a7

Please sign in to comment.