Не удается запустить приложение лямбда-API с помощью Serverless Framework - PullRequest
2 голосов
/ 28 мая 2020

Я пытаюсь использовать serverless-python-requirements и запустить serverless.yml со средой Dockerfile.

Бессерверное развертывание выполнено , но не может запускать события.

org: viluong1610
app: my-first-app
service: keazaccess-api

provider:
  name: aws
  runtime: python3.7
  region: ap-southeast-1

functions:
  app:
    handler: wsgi_handler.handler
    events:
      - http: ANY /
      - http: 'ANY {proxy+}'

custom:
  wsgi:
    app: app.app
    pythonBin: python3 # Some systems with Python3 may require this
    packRequirements: false
  pythonRequirements:
    dockerFile: ./Dockerfile

plugins:
  - serverless-wsgi
  - serverless-python-requirements

My Dockerfile:

FROM centos:7

RUN yum -y update; yum clean all
RUN yum -y install gcc make kernel-devel
RUN yum -y install gcc-c++
RUN yum -y install epel-release; yum clean all
RUN yum -y install python-devel
RUN yum -y install python-pip; yum clean all
RUN yum -y install httpd httpd-tools
RUN yum -y install crontabs

RUN easy_install pip
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
RUN easy_install hashlib
RUN pip install Flask

Моя исходящая отладка:

 Serverless Warning --------------------------------------

  Components v2 engine initialization crashed with: Error: Cannot find module 'protobufjs'
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
      at Function.Module._load (internal/modules/cjs/loader.js:507:25)
      at Module.require (internal/modules/cjs/loader.js:637:17)
      at require (internal/modules/cjs/helpers.js:22:18)
      at Object.<anonymous> (/usr/local/lib/node_modules/serverless/node_modules/@serverless/utils-china/sdk/cls/index.js:1:18)
      at Module._compile (internal/modules/cjs/loader.js:689:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
      at Module.load (internal/modules/cjs/loader.js:599:32)
      at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
      at Function.Module._load (internal/modules/cjs/loader.js:530:3)

Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command wsgi
Serverless: Load command wsgi:serve
Serverless: Load command wsgi:install
Serverless: Load command wsgi:clean
Serverless: Load command wsgi:command
Serverless: Load command wsgi:command:local
Serverless: Load command wsgi:exec
Serverless: Load command wsgi:exec:local
Serverless: Load command wsgi:manage
Serverless: Load command wsgi:manage:local
Serverless: Load command wsgi:flask
Serverless: Load command wsgi:flask:local
Serverless: Load command requirements
Serverless: Load command requirements:clean
Serverless: Load command requirements:install
Serverless: Load command requirements:cleanCache
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Load command dev
platform-sdk fetching: POST https://api.serverless.com/core/tenants/viluong1610/applications/my-first-app/profileValue
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: WARNING: You provided a docker related option but dockerizePip is set to false.
Serverless: Using Python specified in "pythonBin": python3
Serverless: Packaging Python WSGI handler...
platform-sdk fetching: GET https://api.serverless.com/core/tenants/viluong1610/applications/my-first-app
platform-sdk fetching: GET https://api.serverless.com/core/meta
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...
Serverless: Installing dependencies for custom CloudFormation resources...
Serverless: Invoke aws:package:finalize
Serverless: [AWS sts 200 1.113s 0 retries] getCallerIdentity({})
platform-sdk fetching: POST https://api.serverless.com/malt/destinations/create
Serverless: Invoke aws:common:moveArtifactsToPackage
Serverless: Invoke aws:common:validate
Serverless: Safeguards Processing...
Serverless: Safeguards Results:

   Summary --------------------------------------------------

   passed - framework-version
   passed - no-secret-env-vars
   passed - allowed-stages
   passed - no-unsafe-wildcard-iam-permissions
   passed - allowed-runtimes
   passed - allowed-regions
   warned - require-cfn-role

   Details --------------------------------------------------

   1) Warned - no cfnRole set
      details: http://slss.io/sg-require-cfn-role
      Require the cfnRole option, which specifies a particular role for CloudFormation to assume while deploying.


Serverless: Safeguards Summary: 6 passed, 1 warnings, 0 errors
Serverless: Invoke aws:deploy:deploy
Serverless: [AWS cloudformation 200 1.4s 0 retries] describeStacks({ StackName: 'keazaccess-api-dev' })
Serverless: [AWS cloudformation 200 0.464s 0 retries] describeStackResource({ StackName: 'keazaccess-api-dev',
  LogicalResourceId: 'ServerlessDeploymentBucket' })
Serverless: [AWS s3 200 0.507s 0 retries] listObjectsV2({ Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Prefix: 'serverless/keazaccess-api/dev' })
Serverless: [AWS s3 200 0.447s 0 retries] headObject({ Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590637653151-2020-05-28T03:47:33.151Z/keazaccess-api.zip' })
Serverless: [AWS s3 200 0.45s 0 retries] headObject({ Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590637653151-2020-05-28T03:47:33.151Z/custom-resources.zip' })
Serverless: [AWS lambda 200 0.258s 0 retries] getFunction({ FunctionName: 'keazaccess-api-dev-app' })
Serverless: [AWS s3 200 0.446s 0 retries] headObject({ Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590637653151-2020-05-28T03:47:33.151Z/compiled-cloudformation-template.json' })
Serverless: [AWS sts 200 1.282s 0 retries] getCallerIdentity({})
Serverless: Uploading CloudFormation file to S3...
Serverless: [AWS s3 200 0.463s 0 retries] putObject({ Body:
   <Buffer 7b 22 41 57 53 54 65 6d 70 6c 61 74 65 46 6f 72 6d 61 74 56 65 72 73 69 6f 6e 22 3a 22 32 30 31 30 2d 30 39 2d 30 39 22 2c 22 44 65 73 63 72 69 70 74 ... >,
  Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/compiled-cloudformation-template.json',
  ContentType: 'application/json',
  Metadata:
   { filesha256: 'CLXtiTpMNOZGuF2hke9EU2tUhIgyMR0+bctMNDPZlt8=' } })
Serverless: Uploading artifacts...
Serverless: Uploading service keazaccess-api.zip file to S3 (12.3 MB)...
Serverless: [AWS s3 200 0.466s 0 retries] createMultipartUpload({ Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/keazaccess-api.zip',
  ContentType: 'application/zip',
  Metadata:
   { filesha256: 'gvs+zAOaAJTwRlJI91g0UV/5U/nsjDYdiGYTx8LtokM=' } })
Serverless: [AWS s3 200 6.368s 0 retries] uploadPart({ Body:
   <Buffer 17 70 fb 50 8e 01 04 18 1a 24 5d 9c 27 fc ef 14 76 53 36 71 1e 26 42 22 1b 80 81 83 4b 09 44 6e 6e 2e 61 35 85 08 05 06 5e 3c dc 0c 71 81 e6 c8 40 58 ... >,
  ContentLength: 2415822,
  PartNumber: 3,
  Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/keazaccess-api.zip',
  UploadId:
   '1f.EP6kOnv9NtlF2C6KlYp2N4S3yJCOKBYHAprravEPEnT8Sx7TprCHoqOtO2K6Ehb9IYwW80BW454THj3YY5.kdrxeTOWFDtRR9VJ4bKl6TSAnvbzGsSHH30ywGxkrHrLrzHPBZ.TnLCAS3YEiJyA--' })
Serverless: [AWS s3 200 19.549s 0 retries] uploadPart({ Body:
   <Buffer 50 4b 03 04 0a 00 00 00 08 00 00 00 21 00 30 7c 7b 21 7d 00 00 00 b0 00 00 00 10 00 00 00 2e 69 64 65 61 2f 2e 67 69 74 69 67 6e 6f 72 65 5d 8e 41 0e ... >,
  ContentLength: 5242880,
  PartNumber: 1,
  Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/keazaccess-api.zip',
  UploadId:
   '1f.EP6kOnv9NtlF2C6KlYp2N4S3yJCOKBYHAprravEPEnT8Sx7TprCHoqOtO2K6Ehb9IYwW80BW454THj3YY5.kdrxeTOWFDtRR9VJ4bKl6TSAnvbzGsSHH30ywGxkrHrLrzHPBZ.TnLCAS3YEiJyA--' })
Serverless: [AWS s3 200 23.261s 0 retries] uploadPart({ Body:
   <Buffer 5e 66 d9 cf 0a 9b 6a b4 bf 73 24 cc 62 92 39 e6 58 60 91 d3 76 d0 8e 73 18 bf cb 9f 53 4c 71 e2 78 71 38 8d 25 ce 61 74 8f f5 62 92 7d 7e bf 3e c3 2d ... >,
  ContentLength: 5242880,
  PartNumber: 2,
  Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/keazaccess-api.zip',
  UploadId:
   '1f.EP6kOnv9NtlF2C6KlYp2N4S3yJCOKBYHAprravEPEnT8Sx7TprCHoqOtO2K6Ehb9IYwW80BW454THj3YY5.kdrxeTOWFDtRR9VJ4bKl6TSAnvbzGsSHH30ywGxkrHrLrzHPBZ.TnLCAS3YEiJyA--' })
Serverless: [AWS s3 200 0.345s 0 retries] completeMultipartUpload({ MultipartUpload:
   { Parts:
      [ { ETag: '"31486b445ec7a2dd95efce4c15fa8e82"', PartNumber: 1 },
        { ETag: '"be073eebb43830a5afec0b2f33839eea"', PartNumber: 2 },
        { ETag: '"901fcf93edd098835dd4a0a8d7c41801"', PartNumber: 3 },
        [length]: 3 ] },
  Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/keazaccess-api.zip',
  UploadId:
   '1f.EP6kOnv9NtlF2C6KlYp2N4S3yJCOKBYHAprravEPEnT8Sx7TprCHoqOtO2K6Ehb9IYwW80BW454THj3YY5.kdrxeTOWFDtRR9VJ4bKl6TSAnvbzGsSHH30ywGxkrHrLrzHPBZ.TnLCAS3YEiJyA--' })
Serverless: Uploading custom CloudFormation resources...
Serverless: [AWS s3 200 0.233s 0 retries] createMultipartUpload({ Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/custom-resources.zip',
  ContentType: 'application/zip',
  Metadata:
   { filesha256: '0g4dHz+vsw1gU+jsCOPL0VEBvvVFLzfqeMZK3UQzIaQ=' } })
Serverless: [AWS s3 200 0.975s 0 retries] uploadPart({ Body:
   <Buffer 28 93 3d 3c f6 d8 e7 43 fc d9 ee e1 a1 8f c4 03 b1 d7 57 b7 d6 7d 3d 3c 0c 2b 63 11 d9 68 bc 10 1e 1e db de 1e 1e 3b cb f5 f0 d0 10 60 f0 f0 d8 5e 62 ... >,
  ContentLength: 1678369,
  PartNumber: 2,
  Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/custom-resources.zip',
  UploadId:
   'Ebbynlbdgqo1uLe8OD5KjnHrI0MopOef1VsC7xBbtCXG8xK6ZLFqUxBYBO2o9TE7vAN9QVNZbeD.n6OYBfhdrviJAwdzEUDoIxPnPgvlIGjTNWO75yu7NCIfVl8W7v1Y.4HYb4qan2d2EYMdZsZAnQ--' })
Serverless: [AWS s3 200 5.243s 0 retries] uploadPart({ Body:
   <Buffer 50 4b 03 04 14 00 08 00 08 00 f6 18 b6 50 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 52 45 41 44 4d 45 2e 6d 64 8d cd c1 09 80 30 0c 46 e1 7b a7 ... >,
  ContentLength: 5242880,
  PartNumber: 1,
  Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/custom-resources.zip',
  UploadId:
   'Ebbynlbdgqo1uLe8OD5KjnHrI0MopOef1VsC7xBbtCXG8xK6ZLFqUxBYBO2o9TE7vAN9QVNZbeD.n6OYBfhdrviJAwdzEUDoIxPnPgvlIGjTNWO75yu7NCIfVl8W7v1Y.4HYb4qan2d2EYMdZsZAnQ--' })
Serverless: [AWS s3 200 0.568s 0 retries] completeMultipartUpload({ MultipartUpload:
   { Parts:
      [ { ETag: '"1056706512e6ceffde404267acf96074"', PartNumber: 1 },
        { ETag: '"646787e556998dc783a49d2b7a48571b"', PartNumber: 2 },
        [length]: 2 ] },
  Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Key:
   'serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/custom-resources.zip',
  UploadId:
   'Ebbynlbdgqo1uLe8OD5KjnHrI0MopOef1VsC7xBbtCXG8xK6ZLFqUxBYBO2o9TE7vAN9QVNZbeD.n6OYBfhdrviJAwdzEUDoIxPnPgvlIGjTNWO75yu7NCIfVl8W7v1Y.4HYb4qan2d2EYMdZsZAnQ--' })
Serverless: Validating template...
Serverless: [AWS cloudformation 200 1.704s 0 retries] validateTemplate({ TemplateURL:
   'https://s3.amazonaws.com/keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59/serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/compiled-cloudformation-template.json' })
Serverless: Updating Stack...
Serverless: [AWS cloudformation 200 1.796s 0 retries] updateStack({ StackName: 'keazaccess-api-dev',
  Capabilities: [ 'CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM', [length]: 2 ],
  Parameters: [ [length]: 0 ],
  TemplateURL:
   'https://s3.amazonaws.com/keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59/serverless/keazaccess-api/dev/1590638792398-2020-05-28T04:06:32.398Z/compiled-cloudformation-template.json',
  Tags: [ { Key: 'STAGE', Value: 'dev' }, [length]: 1 ] })
Serverless: Checking Stack update progress...
Serverless: [AWS cloudformation 200 1.125s 0 retries] describeStackEvents({ StackName:
   'arn:aws:cloudformation:ap-southeast-1:367319003671:stack/keazaccess-api-dev/39bbed50-a095-11ea-8e70-06a52c6ee8f8' })
....Serverless: [AWS cloudformation 200 0.718s 0 retries] describeStackEvents({ StackName:
   'arn:aws:cloudformation:ap-southeast-1:367319003671:stack/keazaccess-api-dev/39bbed50-a095-11ea-8e70-06a52c6ee8f8' })
.......Serverless: [AWS cloudformation 200 0.642s 0 retries] describeStackEvents({ StackName:
   'arn:aws:cloudformation:ap-southeast-1:367319003671:stack/keazaccess-api-dev/39bbed50-a095-11ea-8e70-06a52c6ee8f8' })
.....
Serverless: Stack update finished...
Serverless: Invoke aws:info
Serverless: [AWS cloudformation 200 0.398s 0 retries] describeStacks({ StackName: 'keazaccess-api-dev' })
Serverless: [AWS cloudformation 200 0.429s 0 retries] listStackResources({ StackName: 'keazaccess-api-dev', NextToken: undefined })
Service Information
service: keazaccess-api
stage: dev
region: ap-southeast-1
stack: keazaccess-api-dev
resources: 19
api keys:
  None
endpoints:
  ANY - https://v4qd3l11l4.execute-api.ap-southeast-1.amazonaws.com/dev
  ANY - https://v4qd3l11l4.execute-api.ap-southeast-1.amazonaws.com/dev/{proxy+}
functions:
  app: keazaccess-api-dev-app
layers:
  None
Serverless: [AWS sts 200 1.306s 0 retries] getCallerIdentity({})
Serverless: [AWS apigateway 200 0.302s 0 retries] getRestApis({ position: undefined, limit: 500 })
Serverless: [AWS apigateway 200 0.187s 0 retries] getDeployments({ restApiId: 'v4qd3l11l4', limit: 500 })
Serverless: [AWS apigateway 200 0.141s 0 retries] getStage({ restApiId: 'v4qd3l11l4', stageName: 'dev' })
Serverless: [AWS apigateway 200 0.306s 0 retries] updateStage({ restApiId: 'v4qd3l11l4',
  stageName: 'dev',
  patchOperations:
   [ { op: 'replace',
       path: '/accessLogSettings/destinationArn',
       value:
        'arn:aws:logs:ap-southeast-1:367319003671:log-group:/aws/api-gateway/keazaccess-api-dev' },
     { op: 'replace',
       path: '/accessLogSettings/format',
       value:
        '{"requestTime":"$context.requestTime","requestId":"$context.requestId","apiId":"$context.apiId","resourceId":"$context.resourceId","resourcePath":"$context.resourcePath","path":"$context.path","httpMethod":"$context.httpMethod","status":"$context.status","authLatency":"$context.authorizer.integrationLatency","integrationLatency":"$context.integrationLatency","integrationStatus":"$context.integrationStatus","responseLatency":"$context.responseLatency","responseLength":"$context.responseLength","errorMessage":"$context.error.message","format":"SLS_ACCESS_LOG","version":"1.0.0"}' },
     { op: 'replace', path: '/*/*/logging/dataTrace', value: 'true' },
     { op: 'replace', path: '/*/*/logging/loglevel', value: 'INFO' },
     [length]: 4 ] })
Serverless: Invoke aws:deploy:finalize
Serverless: [AWS s3 200 0.448s 0 retries] listObjectsV2({ Bucket: 'keazaccess-api-dev-serverlessdeploymentbucket-benlyqs5jo59',
  Prefix: 'serverless/keazaccess-api/dev' })
Serverless: Publishing service to the Serverless Dashboard...
Serverless: [AWS sts 200 1.087s 0 retries] getCallerIdentity({})
Serverless: [AWS cloudformation 200 0.608s 0 retries] describeStacks({ StackName: 'keazaccess-api-dev' })
platform-sdk fetching: POST https://api.serverless.com/core/tenants/viluong1610/applications/my-first-app/services/keazaccess-api/stages/dev/regions/ap-southeast-1/deployments
Serverless: Successfully published your service to the Serverless Dashboard: https://dashboard.serverless.com/tenants/viluong1610/applications/my-first-app/services/keazaccess-api/stage/dev/region/ap-southeast-1

Журнал CloudWatch: введите здесь описание изображения

...