0

我目前使用 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}] {certify,deploy,init,package,template,invoke,manage,rollback,schedule,status,tail,undeploy,unschedule,更新,外壳} ... 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 存储桶用于部署。从第一个实例中重用同一个实例是否安全?我在这里做什么来部署一个新阶段?

4

1 回答 1

2

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
    }
}
于 2019-04-10T08:52:43.590 回答