Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds flask lambda API #1

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Adds flask lambda API #1

wants to merge 13 commits into from

Conversation

techjacker
Copy link
Contributor

@techjacker techjacker commented May 14, 2017

Python Lambda API gateway solution using Flask and Terraform.

Copy link

@LondonAppDev LondonAppDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks great... Clean and easy to understand what's going on.

It was also very easy to get a local dev server up and running (other than the minor points I've noted inline).

My only suggestions are:

  1. Docstrings on the public modules, functions, classes, and methods in errors.py, resources.py and schemas.py.

  2. Using plurals for the endpoint names as oppose to singular nouns. I always find it's a nicer experience consuming APIs that follow this convention: http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#restful. When I was testing the API, I instinctively tried /artists/1/ instead of /artist/1/ which of course returned a 404. I understand this is just a boilerplate but would be good to establish a standard now so projects that base off this are consistent.

Other than that it's all fantastic, high quality code from what I can see!

README.md Outdated
```
Or through docker:
```
doc run --service-ports app

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant to be docker?

README.md Outdated

2. Run development DB
```
docker-compose run db

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't forward port 5432 so running python manage.py db upgrade on next step fails. Running docker-compose up instead works.

@@ -0,0 +1,3 @@
DEBUG = True
SQLALCHEMY_ECHO = True
SQLALCHEMY_DATABASE_URI = 'postgres://app@localhost/app'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't include the password set in docker-compose.yml. Maybe it should be SQLALCHEMY_DATABASE_URI = 'postgres://app:app@localhost/app'? Or alternatively the README updated to to mention the development.py settings file needs to be updated with the PostgreSQL password?

return paginator


@api.route('/healthz', methods=('HEAD', 'GET'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the 'z' deliberate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's a kubernetes convention which seems to be the defacto name for that handler now
https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/

Dockerfile Outdated
apt-get -y install zip

COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice Docker will run as root? Is the Dockerfile just for dev or will it be ran on production? If it's just for dev please ignore this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it's just for local development purposes, if we wanted to use it for deployment I would significantly change the container config

@alanmackenzie
Copy link

I like the reference you flagged up for naming. I will work it into the references for our external API spec and we can treat it as a standard from there.

Copy link

@jszalkowski jszalkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dont separate 'root' template defionitions in multiple files - keep everything in main.tf

bin/destroy Outdated
fi
terraform env select "$ENVIRONMENT"

terraform destroy \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use rather destroy plan instead

@@ -0,0 +1,53 @@
version: '3'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker-compose on ecs cluster? shouldnt it be ecs container definition ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for local development purposes. The plan is to deploy via AWS lambda.

@techjacker
Copy link
Contributor Author

@jszalkowski

Changes made. Please re-review and sign off if correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants