Skip to content

Commit

Permalink
Merge pull request #143 from FloRul/rich_pdf_ingestion_lambda
Browse files Browse the repository at this point in the history
refactor
  • Loading branch information
joelbalcaen authored Apr 4, 2024
2 parents 872a5de + 8df35cc commit 6c25b55
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy Lambdas & Terraform Plan on PR

env:
RICH_PDF_INGESTION: rich_pdf_ingestion
RICH_PDF_INGESTION_ECR_NAME: rich_pdf_ingestion

on:
push:
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
aws ecr describe-repositories --repository-names ${{ vars.RESUME_REQUEST_PROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.RESUME_REQUEST_PROCESSOR_ECR_NAME }}
aws ecr describe-repositories --repository-names ${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }}
aws ecr describe-repositories --repository-names ${{ vars.RESUME_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.RESUME_ECR_NAME }}
aws ecr describe-repositories --repository-names ${{ env.RICH_PDF_INGESTION }} || aws ecr create-repository --repository-name ${{ env.RICH_PDF_INGESTION }}
aws ecr describe-repositories --repository-names ${{ env.RICH_PDF_INGESTION_ECR_NAME }} || aws ecr create-repository --repository-name ${{ env.RICH_PDF_INGESTION_ECR_NAME }}
- name: Generate timestamp
id: timestamp
Expand Down Expand Up @@ -64,8 +64,8 @@ jobs:
docker push $ECR_REGISTRY/${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }}:$IMAGE_TAG
docker build -t $ECR_REGISTRY/${{ vars.RESUME_ECR_NAME }}:$IMAGE_TAG ./lambdas/ResumeProcessor/ResumeFunction
docker push $ECR_REGISTRY/${{ vars.RESUME_ECR_NAME }}:$IMAGE_TAG
docker build -t $ECR_REGISTRY/${{ env.RICH_PDF_INGESTION }}:$IMAGE_TAG ./lambdas/${{ env.RICH_PDF_INGESTION }}/src
docker push $ECR_REGISTRY/${{ env.RICH_PDF_INGESTION }}:$IMAGE_TAG
docker build -t $ECR_REGISTRY/${{ env.RICH_PDF_INGESTION_ECR_NAME }}:$IMAGE_TAG ./lambdas/${{ env.RICH_PDF_INGESTION_ECR_NAME }}/src
docker push $ECR_REGISTRY/${{ env.RICH_PDF_INGESTION_ECR_NAME }}:$IMAGE_TAG
deploy-infra:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -126,5 +126,5 @@ jobs:
-var="resume_request_processor_lambda_repository_name=${{ vars.RESUME_REQUEST_PROCESSOR_ECR_NAME }}" \
-var="resume_request_preprocessor_lambda_repository_name=${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }}" \
-var="resume_lambda_repository_name=${{ vars.RESUME_ECR_NAME }}" \
-var="resume_lambda_repository_name=${{ env.RICH_PDF_INGESTION }} \
-var="rich_pdf_ingestion_repository_name=${{ env.RICH_PDF_INGESTION_ECR_NAME }} \
-auto-approve -no-color -input=false
11 changes: 8 additions & 3 deletions lambdas/rich_pdf_ingestion/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ locals {

data "aws_caller_identity" "current" {}

data "aws_ecr_image" "lambda_image" {
repository_name = var.lambda_repository_name
most_recent = true
}


module "lambda_function_container_image" {
source = "terraform-aws-modules/lambda/aws"
Expand All @@ -19,9 +24,9 @@ module "lambda_function_container_image" {
role_name = "${local.lambda_function_name}-role"
attach_policy_statements = true

create_package = false
image_uri = data.aws_ecr_image.lambda_image.image_uri
package_type = "Image"
create_package = false
image_uri = data.aws_ecr_image.lambda_image.image_uri
package_type = "Image"

policy_statements = {
log_group = {
Expand Down
2 changes: 1 addition & 1 deletion lambdas/rich_pdf_ingestion/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variable "aws_region" {
nullable = false
}

variable "lambda_storage_bucket" {
variable "lambda_repository_name" {
type = string
nullable = false
}
7 changes: 3 additions & 4 deletions terraform/modules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ module "email_receipt_confirmation" {
}

module "rich_pdf_ingestion" {
source = "../lambdas/rich_pdf_ingestion"
aws_region = var.aws_region
lambda_storage_bucket = aws_s3_bucket.lambda_storage.id

source = "../lambdas/rich_pdf_ingestion"
aws_region = var.aws_region
lambda_repository_name = var.rich_pdf_ingestion_repository_name
}
5 changes: 5 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ variable "resume_lambda_repository_name" {
nullable = false
}

variable "rich_pdf_ingestion_repository_name" {
type = string
nullable = false
}

variable "resume_request_processor_lambda_repository_name" {
type = string
nullable = false
Expand Down

0 comments on commit 6c25b55

Please sign in to comment.