DEV Community

Cover image for Infrastructure as code: part-1 (Terraform to emancipate?)
Omer Sayem
Omer Sayem

Posted on

Infrastructure as code: part-1 (Terraform to emancipate?)

Lately, I have been working on a project, which is based on cloud-native architecture (AWS) and I was in a dilemma about the perfect IaC solution. Despite going into detailed project requirements,simply added the draft diagram below.

Alt Text

Now, from the above diagram, it is quite conspicuous that this system is based on some AWS components and it's a messaging system. Firstly, it maybe seems overkill to think about the IaC solution deeply. However, In the long run, it can save a ton of deployment time. Thus, I decided to leverage the IasC solutions, which codifies the entire architecture. There are several tools for managing serverless applications, such as AWS SAM, serverless framework, and terraform. However, for the sake of minimality, I will decide between SAM and serverless framework in this part.

On the one hand, the serverless framework is a provider-agnostic solution. Thus, its possible to deploy FaaS functions into multiple serverless vendors. Interestingly, the Deployment process is magical (Creates s3 buckets to store artifacts automatically) in SF, and indeed, it's easy. Offline testing needs to install an extra package(serverless offline) and does not need a docker.

On the other hand, as SAM is an abstract layer of AWS cloud formation, it is easy for running AWS users. Moreover, it consists of fewer boilerplate.SAM Local creates the same environment as Lambda, which spins up local API gateway and then runs function in docker. Finally, it has deep integration of AWS tools for debugging, testing, and development such as AWS Serverless Application Repository, AWS Toolkit for Visual Studio Code, AWS Cloud9 IDE, Jenkins plugin.

Considering the above options with my solution, I decided to stick with SAM:

  1. Owing to this solution is utterly based on AWS, it will be overkill to use a multi-cloud solution tool.
  2. Development and testing with the more AWS-like tools with SAM may ease the process.
  3. Local development will be more likely to AWS Lambda.

So, until now, AWS sam looks like the perfect solution. Is it really? What about if the business wants to scale it beyond serverless applications? Also, for a big project Cloudformation template is manageable? ( I will give my opinion on part 2, till share your experience )

P.S. Just to ensure, I might provide the entire solution on Github once it is completed.

Top comments (0)