4

我正在使用无服务器来部署 AWS 无服务器堆栈。(即:lambda、sqs、sns)。在尝试部署到 AWS 之前,我想先在本地运行。我已经搜索并查看了适合我用例的localstack 。这是我部署系统的步骤:

  1. 使用 docker 克隆项目并运行整个堆栈。(命令docker-compose up:)
  2. 在我的项目中安装库serverless-localstack并更新serverless.yml

这是我的配置:

plugins:
  - serverless-localstack

custom:
  localstack:
    host: http://localhost
    debug: false
    endpoints:
    stages:
      - local
      - dev
    lambda:
      mountCode: False # Enable this flag to improve performance

之后,我使用命令部署此堆栈:serverless deploy --stage local。但我总是遇到例外。

Serverless: Updating Stack...
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 1 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 2 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 3 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 4 of 4

  Serverless Error ---------------------------------------

  502

这是我的完整部署日志:

Serverless: Generated requirements from /Users/hqt/Documents/avex/requirements.txt in /Users/hqt/Documents/avex/.serverless/requirements.txt...
Serverless: Installing requirements from /Users/hqt/Documents/avex/.serverless/requirements/requirements.txt ...
Serverless: Docker Image: lambci/lambda:build-python2.7
Serverless: Running docker run --rm -v /Users/hqt/Documents/avex/.serverless/requirements\:/var/task\:z -u 0 lambci/lambda\:build-python2.7 python2.7 -m pip install -t /var/task/ -r /var/task/requirements.txt...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...
Serverless: WARNING: Function crawl_twitter_accounts_api has timeout of 900 seconds, however, it's attached to API Gateway so it's automatically limited to 30 seconds.
Serverless: Using serverless-localstack
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
..
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service avex.zip file to S3 (25.08 MB)...
Serverless: Validating template...
Serverless: Skipping template validation: Unsupported in Localstack
Serverless: Updating Stack...
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 1 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 2 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 3 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 4 of 4

  Serverless Error ---------------------------------------

  502

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           11.6.0
     Serverless Version:     1.38.0
Serverless: Generated requirements from /Users/hqt/Documents/avex/requirements.txt in /Users/hqt/Documents/avex/.serverless/requirements.txt...
Serverless: Installing requirements from /Users/hqt/Documents/avex/.serverless/requirements/requirements.txt ...
Serverless: Docker Image: lambci/lambda:build-python2.7
Serverless: Running docker run --rm -v /Users/hqt/Documents/avex/.serverless/requirements\:/var/task\:z -u 0 lambci/lambda\:build-python2.7 python2.7 -m pip install -t /var/task/ -r /var/task/requirements.txt...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...
Serverless: WARNING: Function crawl_twitter_accounts_api has timeout of 900 seconds, however, it's attached to API Gateway so it's automatically limited to 30 seconds.
Serverless: Using serverless-localstack
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
..
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service avex.zip file to S3 (25.08 MB)...
Serverless: Validating template...
Serverless: Skipping template validation: Unsupported in Localstack
Serverless: Updating Stack...
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 1 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 2 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 3 of 4
Serverless: Recoverable error occurred (502), sleeping for 5 seconds. Try 4 of 4

  Serverless Error ---------------------------------------

  502

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           11.6.0
     Serverless Version:     1.38.0

请告诉我如何解决这个问题。

4

0 回答 0