gpt4 book ai didi

aws-sdk - 无法配置以将无服务器堆栈部署到 localstack

转载 作者:行者123 更新时间:2023-12-03 21:05:37 25 4
gpt4 key购买 nike

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

  • 克隆项目并使用 docker 运行整个堆栈。 (命令:docker-compose up)
  • 在我的项目
  • 中安装库 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 。但我总是遇到异常(exception)。
    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

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

    最佳答案

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

    关于aws-sdk - 无法配置以将无服务器堆栈部署到 localstack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54913758/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com