Building Serverless Python Web Services with Zappa
上QQ阅读APP看书,第一时间看更新

The zappa_settings.json file

Once you've finished the questionnaire session, Zappa creates a basic zappa_settings.json file based on your input. zappa_settings.json plays an important role in configuring Zappa with your project. If you initialize Zappa in your existing project (Django/Flask/Pyramid/Bottle), then Zappa automatically detects the type of project and creates the zappa_settings.json file accordingly.

The following is the content of our newly created zappa_settings.json file for the hello world program:

{
"dev": {
"app_function": "hello.app",
"aws_region": "ap-south-1",
"profile_name": "default",
"project_name": "lambda-bottle-p",
"runtime": "python3.6",
"s3_bucket": "zappa-2o2zd8dg4"
}
}

For a Django project, it uses django_settings instead of app_function. django_settings needs to be initialized with the path to your Django settings:

{
"dev": {
"django_settings": "your_project.settings",
"aws_region": "ap-south-1",
"profile_name": "default",
"project_name": "lambda-bottle-p",
"runtime": "python3.6",
"s3_bucket": "zappa-2o2zd8dg4"
}
}

The preceding configuration is enough to deploy a basic Python web application. Let's move on and deploy hello world as a serverless application.