My First Lambda – playing with AWS, part 1

When reading through the whole internet lately I encountered AWS hype.  2015 I remember there was my first contact with this Amazon services but I skipped that somehow and forgot about my account.  Things changed when I learned that this portal allows you not only to host machines and real linux systems but Lambdas.  The code is here, check my Github.

There was some small project always in my head. To have all my money spendings recorded in nicer way than google sheet.  And using some Android money apps was not a solution.  As dev, I deserve to have something more!


I am not goint go provide here N-tish AWS tutorial, but the goal is to record here my steps from starting to play with AWS.

Lambda is cool

Why it’s cool?  Because Lambda is a microservice.  It means, you don’t care to where is it running and how.  You pay only for processing time.  If it is web app you don’t care about time of waiting for user requests.

Write my Lambda!


To start playing with Lambdas you have to have AWS account.  Nothing hard to do.  You will find how to do it in tutorials.

The code

Our first Lambda can be super stupid simple.

Create Lambda, CLI and GUI

There are several ways of creating Lambda.  You can utilize some templates available online.  The easiest way is to use your own role, but the suggested way is to create the separate role for it.


You’d better first get your aws cli using pip for instance, this is the best language to write lambdas though (Python)

Then configure it for your role.  You will need access keys from this page to do it

Then knowing what is your IAM you can configue your CLI

Create lambda GUI

It is possible to create lambda using GUI as from this Web Console. There you will find some useful tool to execute and test your code here.Create lambda CLI

Having CLI configured it is even easier way to create Lambda with CLI

On this github repo I prepared some pre-defined scripts for uploading.  You can treat them as inspiration to make you own „continuous deployment pipeline”.

Move that house!

So there is the time for test!  You can invoke your lambda.  As usual, using Web console or nice and black-and-white CLI
For CLI way you just aws lambda invoke your piece of code.

and the screen with the results of previous operation

Is it working? Prove me!

You can test if the Lambda has been running when invoking Lambda from CLI.  Known good practice is to redirect the output of function to a file, as shown on the previous example.

The way for any developer to communicate with your backend program is to read the logs.  It is possible here on AWS platform, too. And there is no need to use any specific loggers to accomplish it.  Cloudwatch is used when you do any print statement, in case of Python apps.

I encountered one issue several times when trying to browse Cloudwatch logs.  If your invokers role has no access to Logs (IAM policies) you cannot be able to browse or no logs are recorded.  So be careful to execute and browse logs with Policies of templates FULL Logs access or to have policy similar to following:

or you can attach just one of these following:

This project will be developed here thanks to Github.

Next we are going to read write to DB, in part #2.  Stay tuned.