Serverless

Choosing the right tool for your serverless journey.

What tools are available if I want to start building my own serverless applications? We will go over some of the most popular frameworks and tools available for the developer who wants to get started with AWS Lambda.

There are a lot of tools out there to use when building software that are powered by AWS Lambda. These tools aim to ease the process of coding, configuring and deploying the Lambdas themselves but also the surrounding AWS infrastructure. We will discuss the following alternatives:

  • AWS Cloud development kit (CDK)
  • Serverless Framework
  • AWS Serverless Application Model (SAM)
  • Terraform

About AWS CloudFormation

AWS CloudFormation is a service within AWS that lets you group resources (usually AWS resources) into stacks that you can deploy and continuously update. These CloudFormation templates are written in JSON or YAML and manually typing those can be very tedious. Especially when your stack grows to a lot of resources that reference each other in multiple ways. What lots of these frameworks and tools do is to provide an abstraction layer in front of CloudFormation so that the developer can more rapidly create and focus on the business value of the service they are building.

AWS Cloud development kit (CDK)

The AWS CDK went into general availability in the summer of 2019 and has been getting a lot of traction lately. It is an open source framework that lets you create your infrastructure as code instead of CloudFormation. You then generate CloudFormation templates from your code by running the command cdk synthesize.

You can choose from Python, TypeScript, JavaScript, .NET and Java to describe your resources instead of having to do it in pure CloudFormation. This gives you benefits such as code completion and being able to assign resources to variables, which helps you when a resource needs referencing to another one. Another great benefit is that it has helper functions in place to help with common developer use cases. For example setting up a NodeJs Lambda function or constructing ARNs.

The CDK code in the screeenshot will be synthesized to CloudFormation at build time. This example creates a Lambda function, a DynamoDB table and an API Gateway. The example also shows referencing between the resources: for example giving the Lambda function rights to read from the table.

Serverless Framework

This one has been around since 2015 and was called JAWS before quickly changing to its current name. As the very descriptive name says, it’s a framework for building serverless applications! The framework is easy to get started with and setting up an API with a few Lambdas require very little configuration for the developer as the framework takes care of the underlying CloudFormation template.

Because of its specific focus in serverless applications, the framework is not as broad as the CDK and that comes with pros and cons. You will get a lot of help if you are setting up Lambdas or events that trigger those Lambdas, but setting up the surrounding infrastructure such as queues, tables, kinesis streams and cognito user pools will often require you to write pure CloudFormation. At TIQQE, some of us like to create and deploy this surrounding infrastructure with the CDK, while developing the Lambdas  and the API gateway in Serverless Framework.

Serverless Framework is open source and multi-cloud. It’s also extendable with a wide range of plugins created by the community.

Shows the central configuration file in a Serverless Framework service: serverless.yml. When deployed, a Lambda function “myFirstLambda” is created and an API Gateway will be set up with a method to invoke the Lambda at the path /hello.

AWS Serverless Application Model (SAM)

AWS SAM is another framework similar to Serverless Framework that it let’s the developer write less code when building serverless applications. Unlike Serverless Framework, SAM is specific to AWS and its main configuration file template.yml is written with CloudFormation. So if you have previous experience with AWS and CloudFormation you will likely find it easy to get started with SAM. A neat feature in SAM is that it has support to deploy APIs using swagger out of the box. 

Template.yml in a AWS SAM project. Deploying this template will produce the same result as the Serverless Framework example above.

Terraform

This multi-cloud tool for infrastructure as code is worth a mention! It has been around since 2014 and is written in Go. For AWS it uses the aws-sdk to manage resources instead of CloudFormation, which gives the benefit of not having a resource limit of 200 that AWS impose for CloudFormation templates.

How do I choose which one to pick?

It comes down to some characteristics of your application, and a fair bit of personal preference! 

  • Are you building a service with an API endpoint and you have little or no previous experience in AWS or serverless architecture? We recommend you to check out Serverless Framework.
  • Are you not a fan of writing CloudFormation and your architecture needs a lot of infrastructure? Check out AWS CDK.
  • Are you familiar with CloudFormation and want to get started with serverless applications? AWS SAM could be the perfect match! 

There are countless forum posts and articles debating whether to go with AWS SAM or Serverless Framework. The frameworks are very similar and many times it comes down to personal taste. At TIQQE we have lots of experience working with Serverless Framework and some of us would debate that you get the job done in less lines of code with Serverless Framework. With that said, SAM does not have to worry about being generic for multiple clouds and that can be an edge if you are working only with AWS. SAM also defaults to giving Lambda functions least privilege access rights (AWS best practice), while Serverless Frameworks share a role between all Lambdas.

Terraform can be a good match if you are creating infrastructure as code across multiple clouds. While Terraform is capable of doing many things, it is not specialised in serverless technologies and you will have to write a lot of code to achieve the same results as the other frameworks described in this post. Not having a 200 resource limit is nice but should not be a problem that often if you are designing your systems in terms of microservices.

Do you have any comments or questions about this article? Please reach out!

johannes.uhr@tiqqe.com

Serverless

Simply: AWS Lambda

Why should I use AWS Lambda and how does it work? In this blog post I provide you with a practical hands-on guide of how to create your first AWS Lambda service and explain why you should use it to create awesome customer value.

What is AWS Lambda?

With AWS lambda we can write code and execute it without caring about configuring servers.

Why should I use it?

It enables you to quickly develop business relevant code and deliver value for your customers and stakeholders.

How do I start?

First you’re gonna need an AWS account, follow this guide.

Creating our first Lambda

From the AWS console head to Services and search for Lambda select the first option.

Click Create Function

Enter your name for the lambda and select runtime (I’m going with Node.js) Leave everything else default.

Writing code

When your lambda is created you’ll be taken to that lambdas page where you can see and setup lots of information and options about your lambda, let’s not worry too much about that right now and just scroll down to “Function Code”.

Using the inline editor (you are of course able to write code with any IDE you want and deploy it to AWS but I’ll cover that in another post) let’s enter some code, this is what I used.

Testing our code

At the top of the screen click configure test event and create an event to execute the function with.

The event in JSON format

Hit Create and finally click the “Test” button.

After its execution you’ll see the result and the output by clicking Details in the green result box, you can also click (logs) to enter CloudWatch Logs and get a better look into all executions of your lambda.

Good job!

You’ve just created a lambda and the possibilities with it are endless, in future posts I’ll discuss how we can connect an API to our lambda via API Gateway and how we can store our data in the NoSQL database DynamoDB.

Discussion: what about the price?

With Lambda the first million requests each month are alway free after that you pay $0.20 per 1M requests and $0.0000166667 for every GB-second, read more here. Lambda is usually used together with other AWS services that might also incur cost such as Cloudwatch logs which we touched upon in this post, Cloudwatch logs also offer a free tier, 5GB of Log Data Ingestion and 5GB of Log Data Archive, which means nothing we did in this post will result in any cost even if you do no cleanup.
Read more about the economics of cloud here “Cloud is expensive”

I don’t want to use the inline code editor!

Great, me neither, I suggest as a first step either looking into exporting your code to zip and uploading to the lambda

or exploring the Serverless framework, a tool that makes it easy to deploy serverless applications such as Lambda!

You’re welcome to contact me if you have any questions.

Mail: filip.pettersson@tiqqe.com
LinkedIn: Filip Pettersson

Serverless

Re:invent comes to you

TIQQE is hosting re:Invent comes to you – 2019! Welcome to our Örebro office the 5:th of December.

We have been working with Cloud native technologies since 2012 and we’ve learned a whole lot during that journey. We want to share lessons learned and also explain why we are all in on serverless!

re:invent is a yearly event hosted by AWS in Las Vegas it spans over six days and touches on all parts of AWS.

We will treat you to a great evening in Örebro with awesome presentations of the latest and greatest within serverless technology! You will be able to enjoy food and drinks while making new connections with lots of interesting people!

Register today right here

Serverless

AWS Serverless Meetup in Örebro

Yesterday TIQQE co-hosted AWS user group meetup Örebro with Headlight, we did the wildrydes workshop together and it was a great time, we managed to complete the entire workshop with some time left for discussion and reflection.Thanks for everyone who attended and made it an awesome evening, We look forward to hosting and attending more AWS oriented meetups in Örebro in the future!

AWS Serverless Meetup Örebro 2019
Serverless

AWS Advanced Partner

TIQQE has done an amazing journey and has gone from Standard to AWS Advanced partner in record time! We are really proud of what we have achieved in this short time and we are committed to take even more steps to deepen our partnership with AWS!

Looking for AWS experts?

Contact TIQQE! We are the nicest AWS partner in the Nordics! ❤️

Want to work at TIQQE? Check out these open positions:

Customers

Re:invent comes to you

Not everyone are able to join AWS Re:invent in Las Vegas so we decided to take Re:invent to Örebro and invite everyone interested in AWS and Tiqqe.

AWS Re:invent 2018 took place in November 25 to November 30 in Las Vegas, Nevada. As not everyone are able to join, we decided to host our own event in Örebro. We attracted around 40 visitors to our first event, which is quite amazing and proves a big interest for cloud and AWS in Örebro.

David Borgenvik, founder of Tiqqe, started up the evening

We kicked off with some food, drinks and mingle to get everyone in the right mood for the evening. As AWS are broadcasting many of the sessions live, we watched Werner Vogels keynote, which is always a highlight of Re:invent. We had prepared a number of sessions ourselves to inspire people of how we use AWS and serverless technology in real life projects.

The evening was a success and there were a lot of interesting discussions. We will definitively continue with the “Re:invent comes to you” concept next year and hope for even more participants.

Serverless

Our road to Serverless

In the fall of 2015 I worked at a company called e-man Connect. We had been developing cloud based applications, managing cloud infrastructure and developing our own cloud based systems integration service offering to our mid to enterprise customers since 2012. We had detected both increased complexity and increased cost in our infrastructure and we wanted to do something about it. 6 months earlier AWS had made Lambda generally available.

October 2015

Some time around October we landed a contract of developing a Click&Collect Solution for a big international clothing company and I was tasked to develop the app and backend. My initial findings about AWS Lambda and this new emerging software development paradigm called “Serverless” really appealed to me and so we decided to go with lambda and mobile backend. Up until this point we had used Java as our main language but since nodejs was the first runtime to have support on AWS Lambda and I’d been a nodejs fan for quite some time I decided to develop everything using nodejs.

JAWS/The Serverless framework

While setting up the CI/CD pipeline and struggling a bit with how to deploy and setup the CloudFormation I stumbled upon something called JAWS. JAWS was still in beta but showed great promise and made deploying and building micro-services with lambda so much easier! The biggest eye opener for me into the world of serverless and how it compared to all previous software development I had done was that taking code from my computer and presenting it to the world as a highly available, highly scalable and highly stable compute function was just a click away! The complexity and cost was just gone. I could focus on my code, I could focus on the customers idea and how to enable it, I could be a one man team and provide a distributed and highly scaleable application to a big enterprise customer. It was the feeling of having finally waken up and the sense that I never wanted to go to sleep again! JAWS went on to develop in an amazing way! While other Serverless frameworks where born and later died or simply faded out of existence JAWS persisted and grew. It eventually changed it’s name from JAWS to Serverless – https://serverless.com/

I’ve seen the future and it’s name is Serverless

This was still just one Serverless nodejs project in a great sea of other projects with more traditional setups. In November 2015 we got the opportunity to build a web based logistics system for another enterprise customer. We had built similar systems earlier so we started out with one of our Java/Play Framework based templates. But I couldn’t help but feeling a bit sad in leaving the world of Serverless behind. After we had finished the first couple of sprints and had proven our ability to deliver to the customer, we took a really bold decision. Instead of keeping on building our Java monolith we decided to build upon the successful architecture and technology of our previous project and build everything using Serverless and lambda. I’m still somewhat in awe to the level of freedom and confidence our customer showed in us. Today there is somewhere between 30 to 40 people building and managing Serverless applications to this customer all using AWS Lambda and the awesome services that AWS provide as the corner stone of day to day software development.

We eventually went on to make a complete re-write of our complex and costly cloud software integration service offering. Which proved to be a challenging task in it self but in hindsight it was probably both one of the bravest and smartest decisions we could have made!

This year I finally felt ready to start my own company. In June of 2018 TIQQE [tik] was born! I’m very proud to have an awesome team of Cloud Ops Engineers and Serverless developers that are ready to help more customers into the world of Cloud based computing and Serverless software!