free_zed.gitlab.io/content/grandpy-bot-zappa-flask-lam...

2.5 KiB
Raw Permalink Blame History

Title: GrandPy Bot in «serverless» style Date: 2019-03-16 23:34 Category: Réalisations Status: published Summary: Evolution of project 7 realized during the OpenClassrooms course with: Zappa, AWS Lambda & Gitlab-CI/Pages. Lang: en Slug: grandpy-bot-zappa-flask-lambda-gitlab Tags: git, gitlab, devops, flask, dev, zappa, serverless, aws, ci, cd, aws-lambda, python,

This was a student project previously hosted on Github. I updated it to play with:

It is a robot grandfather talking about geographic memories and quoting Wikipedia fetching data over public APIs.

If you can speak French, have a talk with him (^_^)

Run yours !

Need some environment variables to run:

  • EMAIL_ADDRESS (Nominatim API)
  • MAPBOX_API_KEY (Mapbox API)
  • GOO_API_KEY (not used but needed)

Locally:

It works as a simple single-page Flask application:

  • fork-it
  • set up a virtualenv: virtualenv .venv
  • install requirements: pip install -r requirements.txt
  • run it locally: python run.py

On Gitlab:

Set up a AWS IAM profile on your AWS account and add valid environment variables in https://gitlab.com/<namespace>/grandpy/settings/ci_cd:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

Push it back and the CI script will:

  • put chat code on AWS Lambda with the magic of Zappa
  • edit JavaScript with the URL of the AWS API Gateway just updated
  • generate the HTML landing page (with a flask script)
  • deploy statics on gitlab-pages (HTML, images & CSS)

…and voilà, have a chat with GrandPy on https://<namespace>.gitlab.io/grandpy/ (-;


Feel free to give feedback using issues.