Files
pygeoapi/aws-lambda
Richard Law 17ed14107d Add JSON-LD representations (#246)
* Changes to sample pygeopai-config.yml
- improved terms_of_service and contact.url for SEO
- fixes typo for contact.instructions

* whitespace

* dynamically embed JSON-LD representation in head

* json-led representation for root, collections, and collection

* updates sample configuration with metadata that won't cause JSON-LD validation issues

* adds support for feature-level JSON-LD representations of collections and items

* improves consistency between microdata and JSON-LD root metadata

* valid Dataset spatial; and better use of @id

* role →  instructions

* adds jsonld f param to open api definition

* working with new temporal extent interface

* removes comment

* identify and retain NIR/HTTP IDs rather than construct them with reference to pygeoapi

* don't pop a feature.properties id, to retain JSON-LD reference integrity

* add/update tests for inclusion of json-ld responses

* bug fixes

* fix bug where id was assumed to be string

* better url checking

* renames format variable to avoid reserved word

* removes top-level CRS in obs sample config

* add json-ld textMimeType for serverless

* adds flask-cors dependency to allow cors

* moves json-ld-requesting script to bottom of body

* corrects schema.org url

* fixes urls

* adds pyld dependency

* adds tests for json-ld representations (incomplete)

* more tests

* make pyld a dev requirement only

* linting

* changes from revision

* removes merge artifact
2019-12-19 08:33:42 -05:00
..

Using pygeoapi on AWS Lambda Serverless

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 provides Python tooling to interact with AWS lambda. Ensure the environment variables AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY are set and available.

# 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.

AWS Credentials can be created following the instructions at https://serverless.com/framework/docs/providers/aws/guide/credentials/

To install the Serverless environment

npm install serverless

The following serverless plugins are also used

serverless plugin install -n serverless-python-requirements
serverless plugin install -n serverless-wsgi

To deploy to AWS Lambda:

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:

serverless deploy --function app

When deployed, the output will show the URL the app has been deployed to.