Skip to content

Commit

Permalink
found a way to keep the old Submission Lambda function name
Browse files Browse the repository at this point in the history
  • Loading branch information
craigzour committed May 1, 2024
1 parent cba1c19 commit d20d66b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ runs:
LAMBDA_NAME: ${{ inputs.lambda-name }}
IMAGE_TAG: ${{ inputs.image-tag }}
ECR_REGISTRY: ${{ steps.login-ecr-staging.outputs.registry }}
run: aws lambda update-function-code --function-name $LAMBDA_NAME --image-uri $ECR_REGISTRY/$LAMBDA_NAME-lambda:$IMAGE_TAG
run: |
functionName=$([ "$LAMBDA_NAME" == "submission" ] && echo "Submission" || echo "$LAMBDA_NAME")
aws lambda update-function-code --function-name $functionName --image-uri $ECR_REGISTRY/$LAMBDA_NAME-lambda:$IMAGE_TAG
shell: bash

- name: Logout of Staging Amazon ECR
Expand Down
8 changes: 7 additions & 1 deletion aws/lambdas/submission.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
# Form Submission API processing
#

/*
* For the submission Lambda, when working on https://github.com/cds-snc/forms-terraform/pull/626, we decided to not rename the function name
* to avoid any service disruption when releasing to Production. This is due to the web application directly calling the Submission (with a capital S) Lambda.
* All the others Lambda functions have lowercase names.
*/

resource "aws_lambda_function" "submission" {
function_name = "submission"
function_name = "Submission"
image_uri = "${var.ecr_repository_url_submission_lambda}:latest"
package_type = "Image"
role = aws_iam_role.lambda.arn
Expand Down
2 changes: 1 addition & 1 deletion env/cloud/pr_review/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependency "lambdas" {
mock_outputs_merge_with_state = true
mock_outputs_merge_strategy_with_state = "shallow"
mock_outputs = {
lambda_submission_function_name = "submission"
lambda_submission_function_name = "Submission"
}
}

Expand Down
6 changes: 4 additions & 2 deletions lambda-code/deploy-lambda-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ for lambdaFolderPath in $basedir/*/; do
docker tag $repositoryName $ecrRepositoryAddress/$repositoryName
docker push $ecrRepositoryAddress/$repositoryName

printf "${yellowColor}=> Requesting ${lambdaName} Lambda function to use new image. It can fail if the Lambda function is not deployed yet.${reset}\n"
functionName=$([ "$lambdaName" == "submission" ] && echo "Submission" || echo "$lambdaName")

awslocal lambda update-function-code --function-name $lambdaName --image-uri $ecrRepositoryAddress/$repositoryName > /dev/null || continue
printf "${yellowColor}=> Requesting ${functionName} Lambda function to use new image. It can fail if the Lambda function is not deployed yet.${reset}\n"

awslocal lambda update-function-code --function-name $functionName --image-uri $ecrRepositoryAddress/$repositoryName > /dev/null || continue
fi
done

Expand Down

0 comments on commit d20d66b

Please sign in to comment.