0
0
Terraformcloud~3 mins

Why provisioners run scripts on resources in Terraform - The Real Reasons

Choose your learning style9 modes available
The Big Idea

What if your servers could set themselves up perfectly every time without you lifting a finger?

The Scenario

Imagine setting up a new server by hand every time you need one. You log in, install software, configure settings, and repeat this for each server. It feels like doing the same chores over and over.

The Problem

Doing this manually is slow and tiring. You might forget a step or make mistakes. If you have many servers, it becomes a big headache and wastes time.

The Solution

Provisioners let you automate these setup steps by running scripts right after creating resources. This means your servers get ready automatically, without you typing commands each time.

Before vs After
Before
ssh user@server
sudo apt install software
sudo configure settings
After
resource "aws_instance" "example" {
  provisioner "remote-exec" {
    inline = ["sudo apt install software", "sudo configure settings"]
  }
}
What It Enables

You can create fully ready-to-use servers automatically, saving time and avoiding errors.

Real Life Example

A company launches 10 new web servers. Instead of setting each up by hand, provisioners run scripts that install web servers and security settings instantly on all machines.

Key Takeaways

Manual setup is slow and error-prone.

Provisioners automate running scripts on new resources.

This makes infrastructure ready quickly and reliably.