AWS lambda function that generates the anno-docs preview, its main purpose if to offer a more autonomous way of previewing annotations on the editorial side.
This is a work in progress repo.
The following things are assumed to be true in this documentation.
- You are running OSX.
- You are using Python 2.7. (Probably the version that came OSX.)
- You have virtualenv and virtualenvwrapper installed and working.
- You have NPR's AWS credentials stored as environment variables locally.
For more details on the technology stack used with the app-template, see our development environment blog post.
The project contains the following folders and important files:
code
-- Where are lambda function code livestest
-- local tests to check that our code runs locallyfabfile.py
-- Fabric commands for automating setup and deploymentrequirements.txt
-- Python requirements.
Create a lambda function inside AWS using the AWS Console and write down the name you gave to that function and
Also write down the name ot the handler you used.
For example if you have used lambda.lambda_handler
then you will need to create a file on code
called lambda.py
that should have a function with name lambda_handler
in it, that receives as arguments an event
and a context
. That will be the entry point for your lambda execution.
To bootstrap the project:
cd anno-lambda-preview
mkvirtualenv anno-lambda-preview
pip install -r requirements.txt
- Review the code for your lambda function, include all the required libraries in
code/requirements.txt
Since some of the code on this repo should be identical to that of the origin anno-docs repo there's a fabric task that will grab the latest pushed files from master
and place them in their corresponding place in the code
folder. To sync those files run manually:
fab sync_anno_docs_files
-
Create a function in your AWS lambda environment.
-
Finally run:
fab deploy:function=FUNCTION_NAME
Where FUNCTION_NAME
is the name of the created lambda function
The deploy function automatically invokes the sync task mentioned above.