Start With The API

A Pet Project

I have just come to the end of a holiday during which I used a lot of downtime (in very pleasant environments) to start a small dev project. I will provide some more details in a future post of exactly what I am trying to do.

As you will have seen in previous posts, I have been meaning to move off the studying and reading track and onto an actual building and doing track. I have chosen my project well. It is small enough to move quickly but complex enough to introduce a number of different of technologies.

Learning From Doing

Here are some of the things that I have learned to do over the past few weeks.

  • I have used Python and Flask to expose some simple API’s
  • I have served those API’s from a Docker container both locally and on AWS. This means that the API’s can be hit from anywhere on the Web
  • I wanted to add persistence so used AWS DynamoDB both locally and with the managed service
  • I have used Boto to call AWS API’s from my Python code.

It crossed my mind whilst doing all this that maybe I was just hacking. Where exactly does this fit into DevOps practices and my Mission?  My conclusion – I have been following good CI/CD principles (although my tests need some TLC):

  • I have checked everything in to a remote GitHub repo – Dockerfiles, test files, Python code
  • I have pushed Docker images onto Dockerhub
  • I have a pipeline. Update code, build new image, test locally, push image to DockerHub, pull image to an EC2 instance and run from there.   Very manual but simple
  • I have regularly destroyed everything and rebuilt everything using Dockerfiles and Python scripts to do things like recreate DynamoDB tables. Not quite full automation, but very easy to set up elsewhere.

Additionally I have thought hard about how to approach iterations of my code so as to avoid breaking things and to be very quickly able to build and test an end product rather than diving in and changing 10 things at once and then spending hours making it work again.

I have been making sure my code is in a releasable state at all times. An example would be using a variable to point to an in-code list and then pointing it to a database equivalent so that I could easily switch back if it didn’t work. Then when the database was working, delete the in-code list.

Two Key Learning Points

Predictably, it is amazing how much more you learn when actually doing things rather than reading about them. Examples include the difference between using IAM roles and AWS access keys or the flexibility of a managed service NoSQL database.

Secondly, and this is where the title came from, I have started with the APIs. Rather than thinking of an app, I designed a set of API’s before starting and worked out how I wanted each to behave. I have made sure that they are independent and stateless so they can be assembled and called in different ways. At some point I will build a lightweight page that will draw them together in some meaningful way.

This is very different to my old iOS hacking days. I also intend to split the API’s out into their own independent containers which will give me a real world example to play with orchestration tools.

What About AWS SysOps?

I have partially parked this as I was unable to find time to do the exam before my holiday. However, I have created a GitHub repo where I am building cheat sheets.

I have just found out that there is a late September deadline, after which the course changes which means I will have to pick this up again soon.

My Picks

I have been so ensconced in the above, going back to work and family matters that I don’t have too much to add here. I still love GLOW. I still love The Replacements. And here’s a clue, my pet project is very Madonna-centric! More to follow in a future blog.

My other favourite thing recently has been watching Stewart Lee’s Content Provider show. I saw it live but watching it on TV made me laugh just as much second time around.

I have also seen David Byrne live for the first time ever and was blown away. Going again.

Finally, for those studying AWS, I thoroughly recommend A Cloud Guru – they can be found here.

Leave a Reply

Your email address will not be published. Required fields are marked *