Skip to content

donny/zitting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zitting

Zitting is a small AWS Lambda using Gordon that displays top 10 stories from Hacker News.

Background

This project is part of 52projects and the new stuff that I learn through this project: Gordon and Haxor.

Project

Zitting is a small AWS Lambda using Gordon that displays top 10 stories from Hacker News. We use Haxor that provides the Python API to Hacker News. Zitting is accessible from HTTP via API Gateway. The screenshot of the app can be seen below:

Screenshot

Implementation

We create a Gordon project by using the command: gordon startproject zitting. Followed by the command: gordon startapp app to create a new app. We build and deploy the project by running the following command: gordon build && gordon apply.

We then specify the API Gateway integration as can be seen in the following settings.yml:

---
project: zitting
default-region: us-east-1
code-bucket: gordon-fiftytwo-zitting
apps:
  - gordon.contrib.lambdas
  - app

apigateway:
    zittingapi:
        description: Zitting API
        resources:
            /:
                methods: GET
                integration:
                    lambda: app.zitting

The main Python code itself is very small and straight forward:

import json
from hackernews import HackerNews

def handler(event, context):
    hn = HackerNews()
    results = []
    for story_id in hn.top_stories(limit=10):
        results.append(hn.get_item(story_id).title)

    return json.dumps(results)

Conclusion

Gordon is kind of similar to Serverless that I learnt from Quail a few weeks ago. They are basically a framework to simplify AWS Lambda development and deployment. As we can see from the list of features, Gordon aims to be more transparent (i.e. less magic) through simple YAML configuration and the generated CloudFormation templates. This is really great and we can actually deploy using the CloudFormation templates directly.

There is a bug in Gordon related to the query parameters and API Gateway. Nevertheless, Gordon is a great tool and I can see using it in the future.

About

A small AWS Lambda using Gordon that displays top 10 stories from Hacker News

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages