Skip to main content

Why Cloudformation template over boto3?


Why Cloudformation template is preferred over boto3 to provision infrastructure in AWS?


1. Zero cost.

There is no cost for using the CloudFormation template to provision resources. On the other hand, if the resources are provisioned using boto3 in lambda, execution does cost money. Even if the price is negligible, every penny helps.

2. Scaleability.

If the resource provision takes more than 15 minutes, it is impossible to provide the resource using lambda directly. In provisioning large resources with heavy bootstrap installations, it could be possible to hit those limits.

3. Fail-Safe.

When the resource provision fails for any reason, lambda doesn't take responsibility to clean up the resources instantiated so far unless it is handled explicitly. On the other hand, CloudFormation Stack does a clean rollback by reverting to the initial state. It does save money if the resources are cleaned up appropriately.

4. Less error-prone.

There is only one way (declarative using JSON or YAML) to express the intent in the CloudFormation template, and it is validated when creating the stack. On the other hand, when expressing it in a programmatic way, unless it is supported by high-quality tests, it may be error-prone. Also, CloudFormation guarantees that only provisioning of resources happens, on the other hand, boto3 opens up all AWS APIs and it puts the onus on developers to behave properly (Say, no accident deletion of S3 folder happens). An analogy is that writing in SQL is less error-prone than expressing it in any imperative language such as Java or .NET.

5. Maintainability.

The CloudFormation template is the standard IaC for AWS. Anyone who worked on the CloudFormation template can easily understand and maintain it. It's easy to compare different versions for any changes, as the structure is pretty much fixed. It's immune to breaking API changes, as it is declarative.

6. Drift detection.

CloudFormation stacks have the ability to detect any manual changes in certain resources. No such monitoring ability is possible with lambda provisioning, as it is a fire and forget operation.

Comments

Popular posts from this blog

Six ways to land rovers on Mars.

Six ways to land robotic rovers on Mars Mars Rover problem is a popular problem statement used by companies to check object orientation and test-driven development skills. In this article, we'll take the core problem statement and see how the solution evolves through six different levels. Knowledge of high school level maths and little python helps to follow this article. The actual Problem Statement: A squad of robotic rovers is to be landed by NASA on a plateau on Mars. This plateau, which is curiously rectangular, must be navigated by the rovers so that their on-board cameras can get a complete view of the surrounding terrain to send back to Earth. A rover's position is represented by a combination of x and y coordinates and a letter representing one of the four cardinal compass points. The plateau is divided up into a grid to simplify navigation. An example position might be 0, 0, N, which means the rover is in the bottom left corner facing North. In order t

Productivity improvement for remote teams!

The typical working hours in IT companies are from 10 am to 6 pm, though it could extend beyond this time depending on the nature of the project. Usually, we expect everyone to put in about 8 hours a day. There are two broad categories to classify these eight hours: Collaboration time and Core working time.  Collaboration time is when interactions with others are needed and includes all the client meetings, standups, team huddles, and discussions. Ideally, these are the hours that enable individuals to complete their work. Individuals in the team have limited choices on when these meetings have to happen as it could involve multiple stakeholders. Core working time is when the actual work gets done and is the productive hours of the individual. The more focused the individual is, the more effective they are.  These two times overlap with regular office working hours and are not conducive to peak productivity. Some teams strive to have dedicated Core working hours when there are no