Rewriting In Python 3.6 On AWS Lambda With Chalice

If you are using and depending on the service, please be aware that the entire code base will be swapped out and replaced with new code before the end of May, 2017.

Ideally, consumers of the API will notice no changes, but if you are concerned, you can test out the new implementation using this temporary endpoint:

For example:


This new endpoint uses the same timer database, so all timers can be queried and set using either endpoint.

At some point before the end of May, the new code will be activated by the standard endpoint.


When the service was built two years ago, the only language supported by AWS Lambda was NodeJS 0.10. The API Gateway service was console only, and quite painful to set up.

It is two years later, and Amazon is retiring NodeJS 0.10. AWS Lambda functions written with this language version will stop working at the end of May (a 1 month extension from the original April deadline).

Though AWS Lambda now supports NodeJS 6.10, I decided to completely rewrite the code for in Python 3.6, for which support was just announced.

I’ve also been wanting to try out chalice for a long time now. Since uses API Gateway and AWS Lambda, this was the perfect opportunity, especially since chalice now also supports Python 3.6.

Though I ran into a few issues trying to get chalice stages and environment variables to work, the project went far easier than the initial implementation, and I am happy with the result.


The chalice software makes creating APIs with Python a pleasure.

These four lines of code are an example of how easy it is to define an API with chalice. This is how the timer set API is defined.

from chalice import Chalice
app = Chalice(app_name='timercheck')

def set_timer(timer, count):

The biggest benefit is that chalice takes care of all of the API Gateway hassles.

After a chalice deploy, all I had to do to make this production worthy was:

  • Create an ACM certificate

  • Point an API Gateway custom domain at the chalice-created API Gateway stage, using the certificate.

  • Add the host record to DNS in Route 53 for the resulting API Gateway CloudFront distribution.

The entire new source for the service is available in the timercheck repository on GitHub.