diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 654a7e6..9e422a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -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 @@ -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' @@ -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 \ No newline at end of file diff --git a/lambdas/rich_pdf_ingestion/lambda.tf b/lambdas/rich_pdf_ingestion/lambda.tf index 8262356..3f64fb4 100644 --- a/lambdas/rich_pdf_ingestion/lambda.tf +++ b/lambdas/rich_pdf_ingestion/lambda.tf @@ -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" @@ -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 = { diff --git a/lambdas/rich_pdf_ingestion/variables.tf b/lambdas/rich_pdf_ingestion/variables.tf index 2c4d097..ae99210 100644 --- a/lambdas/rich_pdf_ingestion/variables.tf +++ b/lambdas/rich_pdf_ingestion/variables.tf @@ -3,7 +3,7 @@ variable "aws_region" { nullable = false } -variable "lambda_storage_bucket" { +variable "lambda_repository_name" { type = string nullable = false } \ No newline at end of file diff --git a/terraform/modules.tf b/terraform/modules.tf index da837ab..8bd97ea 100644 --- a/terraform/modules.tf +++ b/terraform/modules.tf @@ -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 } diff --git a/terraform/variables.tf b/terraform/variables.tf index 0655199..8e2e13a 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -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