0
0
Terraformcloud~5 mins

Why IaC over manual provisioning in Terraform - Performance Analysis

Choose your learning style9 modes available
Time Complexity: Why IaC over manual provisioning
O(n)
Understanding Time Complexity

We want to understand how the time to set up cloud resources changes when using Infrastructure as Code (IaC) compared to doing it manually.

Specifically, how does the number of steps grow as we add more resources?

Scenario Under Consideration

Analyze the time complexity of provisioning multiple cloud resources using Terraform.

resource "aws_instance" "example" {
  count         = var.instance_count
  ami           = "ami-123456"
  instance_type = "t2.micro"
}

variable "instance_count" {
  type    = number
  default = 3
}

This code creates a number of virtual machines equal to instance_count automatically.

Identify Repeating Operations

Look at what happens repeatedly when this code runs.

  • Primary operation: Creating each virtual machine (API call to cloud provider)
  • How many times: Once per instance, so equal to instance_count
How Execution Grows With Input

As you increase the number of instances, the number of API calls grows directly with it.

Input Size (n)Approx. API Calls/Operations
1010
100100
10001000

Pattern observation: The number of operations grows in a straight line with the number of resources.

Final Time Complexity

Time Complexity: O(n)

This means the time to provision grows directly with how many resources you create.

Common Mistake

[X] Wrong: "Using IaC means provisioning time stays the same no matter how many resources I add."

[OK] Correct: Each resource still needs to be created, so time grows with the number of resources, but IaC automates and manages this growth efficiently.

Interview Connect

Understanding how provisioning time grows helps you explain why automation with IaC is better than manual steps, showing you grasp practical cloud operations.

Self-Check

"What if we added a module that provisions multiple resources in parallel? How would the time complexity change?"