无法配置将无服务器堆栈部署到本地堆栈

时间:2019-02-27 20:14:48

标签: aws-sdk serverless atlassian-localstack

我正在使用serverless来部署AWS无服务器堆栈。 (即:lambda,sks,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

请告诉我如何解决此问题。

1 个答案:

答案 0 :(得分:0)

我不会说如何解决它,但是也许问题是您使用的是python并将其收集在容器lambci / lambda:build-python2.7中。可能的问题是在容器之间传输带有代码的存档-从lambci / lambda到localstack。 我用nodejs重播,一切正常