Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
66 stars 23 forks source link

Deployment as serverless application does not work #153

Open demeringo opened 1 year ago

demeringo commented 1 year ago

Bug description

Current version of API cannot be deployed as serverless app anymore (see #152).

To Reproduce

Try to deploy using serverless framework: deployment fails.

npm i
serverless deploy --stage dev --verbose

Deploying boavizta-api to stage dev (eu-west-1)

Packaging
Generating requirements.txt from Pipfile
Parsed requirements.txt from Pipfile in /home/olivier/atelier/boavizta/boaviztapi/.serverless/requirements.txt
Using static cache of requirements found at /home/olivier/.cache/serverless-python-requirements/ec80065591b22d7da5b1f799d978adee62702c9e636fdd6402f9049b86321529_x86_64_slspyc
Excluding development dependencies for function "app"
Packaging Python Requirements Lambda Layer
Found cached Python Requirements Lambda Layer file
Retrieving CloudFormation stack
Uploading
Uploading CloudFormation file to S3
Uploading State file to S3
Uploading service app.zip file to S3 (279.01 kB)
Uploading service pythonRequirements.zip file to S3 (94.64 MB)
Updating CloudFormation stack
Creating new change set
Waiting for new change set to be created
Change Set did not reach desired state, retrying
Executing created change set
  UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - boavizta-api-dev
  UPDATE_IN_PROGRESS - AWS::Lambda::LayerVersion - PythonRequirementsLambdaLayer
  UPDATE_FAILED - AWS::Lambda::LayerVersion - PythonRequirementsLambdaLayer
  UPDATE_ROLLBACK_IN_PROGRESS - AWS::CloudFormation::Stack - boavizta-api-dev
  UPDATE_COMPLETE - AWS::Lambda::LayerVersion - PythonRequirementsLambdaLayer
  UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - boavizta-api-dev
  DELETE_COMPLETE - AWS::Lambda::LayerVersion - PythonRequirementsLambdaLayer
  UPDATE_ROLLBACK_COMPLETE - AWS::CloudFormation::Stack - boavizta-api-dev

✖ Stack boavizta-api-dev failed to deploy (54s)
Environment: linux, node 19.0.0, framework 3.18.2, plugin 6.2.2, SDK 4.3.2
Credentials: Local, "plmis" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
UPDATE_FAILED: PythonRequirementsLambdaLayer (AWS::Lambda::LayerVersion)
Unzipped size must be smaller than 262144000 bytes (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 30de9f86-b8cd-428f-bde2-735d5a6c19ec; Proxy: null)

View the full error: https://eu-west-1.console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aeu-west-1%3A852378600785%3Astack%2Fboavizta-api-dev%2F7541d4b0-e630-11ec-adeb-0abd2632f243

1 deprecation found: run 'serverless doctor' for more details

This seems to be due to the size of zipped dependencies that exceed AWS limit.

Expected behavior

serverless deploy should work

It may involve adapting the servereless.yml deployment (maybe use a docker image or different layer as a workaround to the heavy dependency zip).

As a workaround, until issue is fixed, we suggest to deploy the API as a docker container (using ECS on AWS for example).

JSON OUTPUT

Additional context

It seems that we have 2 options:

See:

demeringo commented 1 year ago

See also this: https://aws.plainenglish.io/i-have-always-loved-leveraging-serverless-technologies-and-no-service-has-been-used-more-by-me-6c176e52261e