Skip to content

Commit

Permalink
add propagation check to layer update script
Browse files Browse the repository at this point in the history
  • Loading branch information
abbas-khan10 committed Jan 23, 2025
1 parent 6099661 commit dcf923e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/base-lambdas-reusable-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ jobs:
- name: Upload Lambda Function zip to ${{ inputs.lambda_aws_name }}
run: |
sleep 3
export AWS_RETRY_MODE=standard
export AWS_MAX_ATTEMPTS=5
aws lambda update-function-code \
--function-name ${{ inputs.sandbox }}_${{ inputs.lambda_aws_name }} \
--zip-file fileb://build/lambdas/${{ inputs.lambda_handler_name }}/${{ inputs.lambda_handler_name }}.zip
18 changes: 18 additions & 0 deletions lambdas/scripts/lambda_layer_update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import sys
import time

import boto3

Expand Down Expand Up @@ -27,6 +28,7 @@ def start(self):
self.extract_default_layer_arns()
self.extract_updated_layer_arns()
self.update_lambda()
self.propagate_lambda_update()

def extract_default_layer_arns(self):
response = self.client.get_function(FunctionName=self.function_name_aws)
Expand Down Expand Up @@ -63,6 +65,22 @@ def update_lambda(self):
Layers=list(self.updated_lambda_arns.values()),
)

def propagate_lambda_update(self):
retry_count = 3
for i in range(retry_count):
time.sleep(3)
print(f"Propagating lambda layer update attempt {i}...")
response = self.client.client.get_function_configuration(
FunctionName=self.function_name_aws
)
if (
response["State"] == "Active"
and response["LastUpdateStatus "] == "Successful"
):
break

print("Lambda state is not ready, retrying...")


if __name__ == "__main__":
layer_update = LambdaLayerUpdate()
Expand Down

0 comments on commit dcf923e

Please sign in to comment.