add README and zappa example for AWS Lambda
This commit is contained in:
+41
-6
@@ -1,6 +1,41 @@
|
||||
# USING PyGeoAPI on AWS Lambda Serverless
|
||||
# Using pygeoapi on AWS Lambda Serverless
|
||||
|
||||
The included serverless.yml and pygeoapi-serverless-config.yml can be used to deploy PyGeoAPI
|
||||
## Overview
|
||||
|
||||
AWS Lambda Serverless is a service from Amazon that enables publishing
|
||||
code which is executed as on demand functions. The value is here is that
|
||||
the server is only working when requests are made, resulting in more efficient
|
||||
use of server resources as well as managing costs.
|
||||
|
||||
pygeoapi provides a couple of ways to publish to AWS Lambda depending on your
|
||||
environment: zappa and node/serverless.
|
||||
|
||||
## zappa
|
||||
|
||||
[zappa](https://www.zappa.io) provides Python tooling to interact with AWS lambda. Ensure the environment
|
||||
variables `AWS_ACCESS_KEY` and `AWS_SECRET_ACCESS_KEY` are set and available.
|
||||
|
||||
```bash
|
||||
# install zappa
|
||||
pip install zappa
|
||||
|
||||
# set environment variables
|
||||
export AWS_ACCESS_KEY_ID=foo
|
||||
export AWS_SECRET_ACCESS_KEY=bar
|
||||
|
||||
# deploy pygeoapi to AWS Lambda
|
||||
zappa deploy -s zappa_settings.json
|
||||
|
||||
# update
|
||||
zappa update -s zappa_settings.json
|
||||
|
||||
# undeploy
|
||||
zappa undeploy -s zappa_settings.json
|
||||
```
|
||||
|
||||
## node/serverless
|
||||
|
||||
The included `serverless.yml` and `pygeoapi-serverless-config.yml` can be used to deploy pygeoapi
|
||||
on AWS Lambda Serverless Environment.
|
||||
|
||||
This requires Amazon Credentials and the Serverless deployment tool.
|
||||
@@ -9,26 +44,26 @@ AWS Credentials can be created following the instructions at https://serverless.
|
||||
|
||||
To install the Serverless environment
|
||||
|
||||
```shell
|
||||
```bash
|
||||
npm install serverless
|
||||
```
|
||||
|
||||
The following serverless plugins are also used
|
||||
|
||||
```
|
||||
```bash
|
||||
serverless plugin install -n serverless-python-requirements
|
||||
serverless plugin install -n serverless-wsgi
|
||||
```
|
||||
|
||||
To deploy to AWS Lambda:
|
||||
|
||||
```
|
||||
```bash
|
||||
serverless deploy
|
||||
```
|
||||
|
||||
Once deployed, if you only need to update the code and not anything in the serverless configuration, you can update the function using:
|
||||
|
||||
```
|
||||
```bash
|
||||
serverless deploy --function app
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"dev": {
|
||||
"app_function": "pygeoapi.flask_app.APP",
|
||||
"profile_name": null,
|
||||
"project_name": "pygeoapi",
|
||||
"runtime": "python3.6",
|
||||
"s3_bucket": "zappa-pwpqh2twb",
|
||||
"aws_region": "us-east-2"
|
||||
"environment_variables": {
|
||||
"PYGEOAPI_CONFIG": "pygeoapi-config.yml"
|
||||
"PYGEOAPI_OPENAPI": "pygeoapi-openapi.yml"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user