使用Zappa的新分支/阶段

时间:2019-04-02 12:26:41

标签: python-3.x aws-lambda zappa python-zappa

我目前正在使用Zappa / Flask(Py 3.7)在AWS Lambda上启用API

我的zappa_Settings.json文件如下所示:

{
    "beta": {
        "app_function": "application.application",
        "profile_name": "changed",
        "project_name": "changed",
        "runtime": "python3.7",
        "s3_bucket": "zappa-<obscured>"
    }

}

但是,我们现在正在研究一组新功能,并认为我们有一个单独的分支或阶段,例如“测试”,在部署到实际环境之前,我们将其部署并评估成熟度。

问题是,请尽我所能,无法从控制台创建新舞台:

zappa init 

崩溃
  

click.exceptions.ClickException:该项目已经有一个   zappa_settings.json文件!

zappa init stage2

产生

  

用法:zappa [-h] [-v] [--color {auto,never,always}]                {证明,部署,初始化,程序包,模板,调用,管理,回滚,计划,状态,尾部,取消部署,取消计划,更新,外壳}                ... zappa:错误:无法识别的参数:stage2

zappa deploy stage2

输出

(botocore 1.12.86 (/home/user/Code/Python/project/lib/python3.6/site-packages), Requirement.parse('botocore<1.11.0,>=1.10.82'), {'boto3'})
Calling deploy for stage stage2..
Error: Please define stage 'stage2' in your Zappa settings.

现在,如果我手动为一个阶段创建一个条目,则需要一个用于部署的s3存储桶。从第一个实例重用相同的对象是否安全?在这里我要做什么以部署新阶段?

1 个答案:

答案 0 :(得分:1)

zappa init只是使您开始使用zappa_settings.json文件,您无需每次都运行此文件来对其进行编辑。

例如。

{
    "beta": {
        "app_function": "application.application",
        "profile_name": "changed",
        "project_name": "changed",
        "runtime": "python3.7",
        "s3_bucket": "zappa-<obscured>"
    },
    "stage2": {
        "app_function": "application.application",
        "profile_name": "changed",
        "project_name": "changed",
        "runtime": "python3.7",
        "s3_bucket": "zappa-<obscured>"
    }
}

但是最好写成这样。

{
    "common": {
        "app_function": "application.application",
        "profile_name": "changed",
        "project_name": "changed",
        "runtime": "python3.7",
        "s3_bucket": "zappa-<obscured>"
    },
    "beta": {
        "extends": "common"
        // additional overrides here
    },
    "stage2": {
        "extends": "common"
        // additional overrides here
    }
}