Amazon Web Services Lambdas — Hello, World!

Dan Pelensky
3 min readAug 9, 2017

--

This week and next week I will be doing a deep dive into Amazon Web Service Lambdas.

A Lambda is essentially a stand alone function that awaits an event and automatically runs when it is triggered. It doesn’t require you to set up a server, is easily scalable and you only pay for what you use.

I haven’t got much experience running functions outside of my local codebase or using APIs so I’m really excited about getting to the bottom of this and seeing how I can run code on a network.

My first challenge over these two weeks is to incorporate a network computer player in my Clojure Tic Tac Toe.

Essentially, when it is the computer’s player I will set up my app to make a call to my Lambda passing in the state of the board, the network player will calculate the best move on the Lambda, and return the integer associated with the space. That will trigger the move, and it will be the next player’s turn again.

Roadmap

  1. Figure out what a Lambda is
  2. Set up the most basic Lambda
  3. Set up a few more/get comfortable with it
  4. Set up a basic Lambda in Clojure
  5. Set up a Lambda with my network computer player logic, but try to get it to return something basic
  6. Set up my network computer player to return the correct move
  7. Research how to use the AWS API Gateway (or find an alternative way to call my Lambda)
  8. Call the network computer player from my command line app

My progress so far

  1. As I noted above, a Lambda is a function that doesn’t require a server to be set up, is always on, and runs when it is called.
  2. The first thing I did was followed a tutorial to set up a basic Hello, World Lambda in Python.
  3. Clojure is hosted on the Java Virtual Machine, therefore shares a lot of similarities with Java. AWS doesn’t natively support Clojure, but it does support Java, so I decided to build a Hello World in Java and host it on a Lambda.
  4. Once I got that to work, I decided to build a Hello World in Clojure, and was really excited to get that to work.

Next steps

I’m now up to step 5 of my roadmap, and feel like this should be very easy. I was trying to get this to work before leaving yesterday, but could not get a separate “Hello, World” function to work in the codebase that holds my network computer player. I’m hoping to get this to work early today so I can move on to getting my computer player to run.

Currently, my computer player accepts a hash-map with the board state (the size of the board, and the sequential moves). I’m not convinced that my Lambda will be able to accept this, so I will look into other ways of passing in this information. Ideally, I’ll be able to send this information in Json format, as this is essentially a hash-map.

I’m cautiously optimistic that I will have some major breakthroughs today, and am hopeful that I can have this network computer player working tomorrow in time for my IPM.

--

--