Discover why running commands directly on servers can cause more harm than good in your cloud setup!
Why provisioners are a last resort in Terraform - The Real Reasons
Imagine you have to set up a new server every day by logging in manually and running commands one by one.
You write scripts that run on the server after it is created to install software or configure settings.
This manual or script-based approach is slow and fragile.
If the server setup fails halfway, you must start over or fix it by hand.
Scripts can break if the server environment changes or if commands run in the wrong order.
Terraform encourages using built-in resource settings and external configuration tools instead of running commands directly on servers.
This keeps infrastructure setup predictable, repeatable, and easier to manage.
resource "aws_instance" "example" { # ... provisioner "remote-exec" { inline = ["sudo apt-get update", "sudo apt-get install -y nginx"] } }
resource "aws_instance" "example" { # ... user_data = <<-EOF #!/bin/bash apt-get update apt-get install -y nginx EOF }
It enables infrastructure to be created and configured reliably without fragile manual steps or scripts that can fail unexpectedly.
Instead of running commands on a new virtual machine to install software, you provide a startup script or use a configuration management tool that runs automatically and consistently.
Manual commands on servers are slow and error-prone.
Provisioners run commands but can cause fragile setups.
Using built-in features or external tools leads to stable, repeatable infrastructure.