A sample to show how to deploy a proxy for the Geoscape APIs into AWS lambda, using Zappa; a simple and scaleable way to use the APIs in front-end JS applicaiotns without exposing your API key.
This example proxys the follow services, with some limited properties:
- Address Prediction, under the
/suggesturl- It defaults to the GNAF dataset and a maxiumum of 10 results
- Single Building from GNAF id, under the
/getBuildingurl- It returns the
footprint2dandmaximumRoofHeightfor the buildings
- It returns the
- An API Key (get it here)
- Python >= 3.6
- An AWS CLI setup with your information
- Clone the repo (or download and unzip)
- Paste your API key into the
api_keyvariable inflaskApp.py - Open a terminal/console/command prompt in the repository directory
- Create virtual environment (
python -m venv env) - Activate virtual envorinemnt (
.\env\scripts\activate) - Install requirements (
pip install -r requirements.txt) - Run
zappa init- Define your environement name, the default is
dev; I'll use that for the rest of the readme - Specify the AWS CLI profile that will be used to create and manage the AWS services
- Set the name for the S3 bucket that Zappa uploads to
- Zappa will auto discover
flaskApp.pyand identify it as the source to use for the lambdas, so just press enter - This one lets you deploy the lambdas to all AWS regions, unless you really want to do this, just press enter.
- Review the results and press enter if good.
- Define your environement name, the default is
- Run
zappa deploy dev - Your proxy will now be available on the supplied URL