localstack-samples / sample-serverless-transcribe

Transcription application deployed using Serverless Framework on LocalStack
Apache License 2.0
2 stars 1 forks source link

Deployment is broken because lambda zip is too big #7

Closed steffyP closed 11 months ago

steffyP commented 1 year ago

The workflow started failing a few weeks ago, indicating that something is wrong with the setup of the sample.

It get stuck with UPDATE_FAILED - AWS::CloudFormation::Stack - aws-node-sample-transcribe-s3-local and then basically runs until the action is killed (after 6 hours).

Running the sample locally and enabling DEBUG=1 revealed that the lambda-zip size is the original issue:

2023-10-16T09:33:34.214  WARN --- [functhread63] l.s.c.resource_provider    : Error calling <bound method ClientCreator._create_api_method.<locals>._api_call of <botocore.client.Lambda object at 0x7f0eb49f2a10>> with params: {'Code': {'S3Bucket': 'aws-node-sample-transcribe-s3-serverlessdeploymentbuck-941f61f0', 'S3Key': 'serverless/aws-node-sample-transcribe-s3/local/1697448798876-2023-10-16T09:33:18.876Z/aws-node-sample-transcribe-s3.zip'}, 'Environment': {'Variables': {'S3_AUDIO_BUCKET': 'aws-node-sample-transcribe-s3-local-records', 'S3_TRANSCRIPTION_BUCKET': 'aws-node-sample-transcribe-s3-local-transcriptions', 'LANGUAGE_CODE': 'en-US'}}, 'FunctionName': 'aws-node-sample-transcribe-s3-local-transcribe', 'Handler': 'src/transcribe.process', 'MemorySize': 1024, 'Runtime': 'nodejs14.x', 'Role': 'arn:aws:iam::000000000000:role/aws-node-sample-transcribe-s3-local-us-east-1-lambdaRole', 'Timeout': 6} for resource: {'Type': 'AWS::Lambda::Function', 'DependsOn': ['TranscribeLogGroup'], 'LogicalResourceId': 'TranscribeLambdaFunction', 'Properties': {'Code': {'S3Bucket': 'aws-node-sample-transcribe-s3-serverlessdeploymentbuck-941f61f0', 'S3Key': 'serverless/aws-node-sample-transcribe-s3/local/1697448798876-2023-10-16T09:33:18.876Z/aws-node-sample-transcribe-s3.zip'}, 'Handler': 'src/transcribe.process', 'Runtime': 'nodejs14.x', 'FunctionName': 'aws-node-sample-transcribe-s3-local-transcribe', 'MemorySize': 1024, 'Timeout': 6, 'Environment': {'Variables': {'S3_AUDIO_BUCKET': 'aws-node-sample-transcribe-s3-local-records', 'S3_TRANSCRIPTION_BUCKET': 'aws-node-sample-transcribe-s3-local-transcriptions', 'LANGUAGE_CODE': 'en-US'}}, 'Role': 'arn:aws:iam::000000000000:role/aws-node-sample-transcribe-s3-local-us-east-1-lambdaRole'}, 'SpecifiedProperties': {'Code': {'S3Bucket': 'aws-node-sample-transcribe-s3-serverlessdeploymentbuck-941f61f0', 'S3Key': 'serverless/aws-node-sample-transcribe-s3/local/1697448798876-2023-10-16T09:33:18.876Z/aws-node-sample-transcribe-s3.zip'}, 'Handler': 'src/transcribe.process', 'Runtime': 'nodejs14.x', 'FunctionName': 'aws-node-sample-transcribe-s3-local-transcribe', 'MemorySize': 1024, 'Timeout': 6, 'Environment': {'Variables': {'S3_AUDIO_BUCKET': 'aws-node-sample-transcribe-s3-local-records', 'S3_TRANSCRIPTION_BUCKET': 'aws-node-sample-transcribe-s3-local-transcriptions', 'LANGUAGE_CODE': 'en-US'}}, 'Role': 'arn:aws:iam::000000000000:role/aws-node-sample-transcribe-s3-local-us-east-1-lambdaRole'}}
2023-10-16T09:33:34.218 DEBUG --- [functhread63] l.s.c.e.template_deployer  : Error applying changes for CloudFormation stack "aws-node-sample-transcribe-s3-local": An error occurred (InvalidParameterValueException) when calling the CreateFunction operation: Unzipped size must be smaller than 262144000 bytes Traceback (most recent call last):
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/engine/template_deployer.py", line 1172, in _run
    self.do_apply_changes_in_loop(changes, stack)
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/engine/template_deployer.py", line 1246, in do_apply_changes_in_loop
    self.apply_change(change, stack=stack)
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/engine/template_deployer.py", line 1361, in apply_change
    progress_event = executor.deploy_loop(resource_provider_payload)  # noqa
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/resource_provider.py", line 656, in deploy_loop
    event = self.execute_action(resource_provider, payload)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/resource_provider.py", line 725, in execute_action
    return resource_provider.create(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/resource_provider.py", line 410, in create
    return self.create_or_delete(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/resource_provider.py", line 553, in create_or_delete
    result = invoke_function(
             ^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/resource_provider.py", line 272, in invoke_function
    raise e
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/services/cloudformation/resource_provider.py", line 251, in invoke_function
    result = function(**params)
             ^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/botocore/client.py", line 535, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/code/localstack/.venv/lib/python3.11/site-packages/botocore/client.py", line 980, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidParameterValueException: An error occurred (InvalidParameterValueException) when calling the CreateFunction operation: Unzipped size must be smaller than 262144000 bytes
joe4dev commented 12 months ago

@sannya-singal @steffyP The same might have just happened in this run for the PR https://github.com/localstack-samples/sample-serverless-transcribe/pull/8 (unrelated to the PR changes):

   UPDATE_FAILED - AWS::CloudFormation::Stack - aws-node-sample-transcribe-s3-local
Error: The operation was canceled.

👉 We should set a much shorter timeout in the GH action timeout-minutes: 10 (adjust accordingly)

sannya-singal commented 12 months ago

@joe4dev I have fixed the issue in #9. Thanks!