-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batcher Lambda, infrastructure and build #2728
Merged
+186
−10
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5d26081
add new docker setup and aws lambda rie client
kenoir ad890a1
Apply auto-formatting rules
weco-bot fd1537a
use same container in ecs & lambda
kenoir ad122fd
add deploy script
kenoir 1726946
Apply auto-formatting rules
weco-bot 5663d26
use release tag of terraform-aws-ecs-service now merged
kenoir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
PIPELINE_NAMESPACE="catalogue-$PIPELINE_DATE" | ||
REPOSITORY_URI="760097843905.dkr.ecr.eu-west-1.amazonaws.com" | ||
|
||
for SERVICE_NAME in "$@" | ||
do | ||
IMAGE_URI="${REPOSITORY_URI}"/uk.ac.wellcome/"${SERVICE_NAME}":"env.${PIPELINE_DATE}" | ||
FUNCTION_NAME="${PIPELINE_NAMESPACE}"-"${SERVICE_NAME}" | ||
|
||
echo "Deploying ${IMAGE_URI} to ${FUNCTION_NAME}, @ $(date) ..." | ||
|
||
echo "Current lambda configuration for ${FUNCTION_NAME}:" | ||
aws lambda get-function-configuration \ | ||
--function-name "$FUNCTION_NAME" \ | ||
--no-cli-pager | ||
|
||
echo "Updating lambda configuration ..." | ||
echo "Using ${IMAGE_URI}:" | ||
aws lambda update-function-code \ | ||
--function-name "$FUNCTION_NAME" \ | ||
--image-uri "${IMAGE_URI}" \ | ||
--no-cli-pager | ||
|
||
|
||
echo "Updated lambda configuration, (waiting for update @ $(date)}):" | ||
aws lambda wait function-updated \ | ||
--function-name "$FUNCTION_NAME" \ | ||
--no-cli-pager | ||
|
||
echo "New lambda configuration complete (@ $(date)), config after change:" | ||
aws lambda get-function-configuration \ | ||
--function-name "$FUNCTION_NAME" \ | ||
--no-cli-pager | ||
|
||
echo "Done deploying ${FUNCTION_NAME} @ $(date)! 🚀" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
FROM public.ecr.aws/docker/library/eclipse-temurin:11-jre-alpine | ||
FROM public.ecr.aws/amazoncorretto/amazoncorretto:11 as base | ||
|
||
LABEL maintainer = "Wellcome Collection <[email protected]>" | ||
|
||
RUN apk add --no-cache bash | ||
|
||
ADD target/universal/stage /opt/docker | ||
|
||
WORKDIR /opt/docker | ||
|
||
FROM base as ecs | ||
|
||
ENTRYPOINT ["/opt/docker/bin/batcher"] | ||
|
||
FROM base | ||
|
||
ENTRYPOINT [ "/usr/bin/java", "-cp", "./lib/*", "com.amazonaws.services.lambda.runtime.api.client.AWSLambda" ] | ||
|
||
CMD ["weco.pipeline.batcher.LambdaMain::handleRequest"] |
19 changes: 19 additions & 0 deletions
19
pipeline/relation_embedder/batcher/src/main/scala/weco/pipeline/batcher/LambdaMain.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package weco.pipeline.batcher | ||
|
||
import com.amazonaws.services.lambda.runtime.{Context, RequestHandler} | ||
import grizzled.slf4j.Logging | ||
|
||
import java.util.{Map => JavaMap} | ||
|
||
object LambdaMain | ||
extends RequestHandler[JavaMap[String, String], String] | ||
with Logging { | ||
|
||
override def handleRequest( | ||
event: JavaMap[String, String], | ||
context: Context | ||
): String = { | ||
info(s"running batcher lambda, got event: $event") | ||
"Done" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
locals { | ||
namespace = "catalogue-${var.pipeline_date}" | ||
|
||
name = "${local.namespace}-${var.service_name}" | ||
image_tag = var.tag_override != "" ? var.tag_override : "env.${var.pipeline_date}" | ||
} | ||
|
||
data "aws_ecr_repository" "repository" { | ||
name = var.ecr_repository_name | ||
} | ||
|
||
data "aws_ecr_image" "lambda_image" { | ||
repository_name = data.aws_ecr_repository.repository.name | ||
image_tag = local.image_tag | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module "pipeline_step" { | ||
source = "github.com/wellcomecollection/terraform-aws-lambda.git?ref=v1.1.1" | ||
|
||
name = local.name | ||
package_type = "Image" | ||
image_uri = "${data.aws_ecr_repository.repository.repository_url}@${data.aws_ecr_image.lambda_image.id}" | ||
timeout = var.timeout | ||
memory_size = var.memory_size | ||
description = var.description | ||
|
||
environment = { | ||
variables = var.environment_variables | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
variable "tag_override" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "ecr_repository_name" { | ||
type = string | ||
} | ||
|
||
variable "service_name" { | ||
type = string | ||
} | ||
|
||
variable "description" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "pipeline_date" { | ||
type = string | ||
} | ||
|
||
|
||
variable "environment_variables" { | ||
type = map(string) | ||
description = "Arbitrary environment variables to give to the Lambda" | ||
default = {} | ||
} | ||
|
||
variable "timeout" { | ||
default = 600 | ||
description = "lambda function timeout" | ||
} | ||
|
||
variable "memory_size" { | ||
default = 1024 | ||
description = "lambda function memory size" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect