Merge pull request #606 from christophersbarrett/support-serverless-fixes

Serverless fixes
This commit is contained in:
Tom Kralidis
2021-01-25 09:01:19 -05:00
committed by GitHub
3 changed files with 33 additions and 11 deletions
+16 -1
View File
@@ -36,14 +36,23 @@ 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.
on AWS Lambda Serverless Environment.
This requires Amazon Credentials and the Serverless deployment tool.
AWS Credentials can be created following the instructions at https://serverless.com/framework/docs/providers/aws/guide/credentials/
Move serverless configs to root directory:
```bash
mv serverless.yml ..
mv pygeoapi-server-config.yml ..
cd ..
```
To install the Serverless environment
```bash
npm install serverless
```
@@ -55,6 +64,12 @@ serverless plugin install -n serverless-python-requirements
serverless plugin install -n serverless-wsgi
```
To test the application as a lambda locally:
```bash
serverless wsgi server
```
To deploy to AWS Lambda:
```bash
+2 -2
View File
@@ -32,11 +32,11 @@ server:
bind:
host: 0.0.0.0
port: 80
url: /dev/
url: /
mimetype: application/json; charset=UTF-8
encoding: utf-8
language: en-US
cors: true
cors: false
pretty_print: true
limit: 10
# templates: /path/to/templates
+15 -8
View File
@@ -31,19 +31,27 @@ service: pygeoapi
provider:
name: aws
runtime: python3.6
runtime: python3.8
# region: us-west-2
# rolePermissionsBoundary: <arn for permission boundary>
# deploymentBucket: <name to deployment bucket>
# role: <arn for pre-existing lambda execution role>
# vpc:
# subnetIds:
# - subnet-id1
# - subnet-id2
# securityGroupIds:
# - sg-id1
# you can define service wide environment variables here
# environment:
# variable1: value1
plugins:
- serverless-python-requirements
- serverless-wsgi
custom:
wsgi:
app: pygeoapi.flask_app.APP
packRequirements: true
pythonBin: python3
app: pygeoapi/flask_app.APP
packRequirements: false
textMimeTypes:
- application/ld+json
functions:
@@ -51,6 +59,5 @@ functions:
handler: wsgi_handler.handler
events:
- http: ANY /
- http: 'ANY {proxy+}'
environment:
PYGEOAPI_CONFIG: pygeoapi-config.yml
PYGEOAPI_CONFIG: pygeoapi-serverless-config.yml