8

I am try update a lambda by zappa, I created virtualenv and active virtualenv and install libraries, but in the moment run zappa update enviroment, I have this problem: How can i fix this :(

 zappa update qa
(pip 18.1 (/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages), Requirement.parse('pip>=20.3'), {'pip-tools'})
Calling update for stage qa..
Downloading and installing dependencies..
Packaging project as zip.
Uploading maximo-copy-customers-qa-1637639364.zip (6.0MiB)..
100%|███████████████████████████████████████████████████████████████| 6.32M/6.32M [00:09<00:00, 664kB/s]
Updating Lambda function code..
Updating Lambda function configuration..
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/zappa/cli.py", line 2778, in handle
    sys.exit(cli.handle())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/zappa/cli.py", line 512, in handle
    self.dispatch_command(self.command, stage)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/zappa/cli.py", line 559, in dispatch_command
    self.update(self.vargs['zip'], self.vargs['no_upload'])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/zappa/cli.py", line 979, in update
    layers=self.layers
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/zappa/core.py", line 1224, in update_lambda_configuration
    Layers=layers
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceConflictException: An error occurred (ResourceConflictException) when calling the UpdateFunctionConfiguration operation: The operation cannot be performed at this time. An update is in progress for resource: arn:aws:lambda:us-east-1:937280411572:function:maximo-copy-customers-qa
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
daniel____
  • 93
  • 1
  • 7
  • I am also facing this error from yesterday. Seems like some change in AWS is causing this error. – eldos Nov 24 '21 at 07:36
  • I feel if we add `time.sleep` here, it should fix the issue https://github.com/ib-devs/Zappa/blob/apigateway_stages_multiple_routes_support/zappa/cli.py#L845 – eldos Nov 24 '21 at 07:42
  • I can fix this problem upgrade zappa version and change python version inside virtual enviroment to 3.8 – daniel____ Nov 28 '21 at 22:44

3 Answers3

5

I would add a more sophisticated solution what mentioned LiriB earlier. Use the aws lambda cli which has the function-updated command (documentation).

Example: aws lambda wait function-updated --function-name "$FN_NAME"

This command will wait until the function is updated. In case it is not upated in 5 minutes, it will stop the execution.

Peter Kusza
  • 361
  • 3
  • 11
4

You should wait for function code update to complete before proceeding with update of function configuration. Inserting the following shell script between the steps can keep the process waiting:

STATE=$(aws lambda get-function --function-name "$FN_NAME" --query 'Configuration.LastUpdateStatus' --output text)
while [[ "$STATE" == "InProgress" ]]
do
    echo "sleep 5sec ...."
    sleep 5s
    STATE=$(aws lambda get-function --function-name "$FN_NAME" --query 'Configuration.LastUpdateStatus' --output text)
    echo $STATE
done
LiriB
  • 814
  • 8
  • 12
1

Add to your zappa_settings.json:

"lambda_description": "aws:states:opt-out"

Zappa issue about it