diff --git a/aws-lambda/README.md b/aws-lambda/README.md index 147c568..678b27a 100644 --- a/aws-lambda/README.md +++ b/aws-lambda/README.md @@ -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 diff --git a/aws-lambda/pygeoapi-serverless-config.yml b/aws-lambda/pygeoapi-serverless-config.yml index 57e3ece..411289c 100644 --- a/aws-lambda/pygeoapi-serverless-config.yml +++ b/aws-lambda/pygeoapi-serverless-config.yml @@ -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 diff --git a/aws-lambda/serverless.yml b/aws-lambda/serverless.yml index 1b41f23..89937a8 100644 --- a/aws-lambda/serverless.yml +++ b/aws-lambda/serverless.yml @@ -31,19 +31,27 @@ service: pygeoapi provider: name: aws - runtime: python3.6 + runtime: python3.8 + # region: us-west-2 + # rolePermissionsBoundary: + # deploymentBucket: + # 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