πŸ”— Repo: github.com/Push/terraform-aws-labs/day19

🎯 Goal: Understand provisioners β€” the last-resort tool for bootstrapping, with clear warnings and best-practice patterns.

βœ… You’ll master:


🧠 Why Provisioners? (The Right Context)

❌ Anti-Pattern:

# DON'T do this in production!
provisioner "remote-exec" {
  inline = ["sudo apt install nginx", "sudo systemctl start nginx"]
}

βœ… Legitimate Uses:

πŸ’‘ Golden Rule:

β€œIf your provisioner runs >5s β€” bake it into an AMI instead.”

(See Day 25: Packer + AMI pipelines)


πŸ“¦ Provisioner Cheat Sheet

Provisioner Runs On Use Case Risk Level
local-exec Your laptop curl healthcheck, echo "DNS: $IP" βœ… Low
remote-exec EC2 (via SSH) One-time config, cluster join ⚠️ Medium (SSH failures)
file EC2 (via SSH) Copy configs, scripts, certs ⚠️ Medium (permissions, paths)

⚠️ Critical Limitations:


✏️ Hands-On: Provisioners in Action

πŸ”Ή File Structure (/day19/)

day19/
β”œβ”€β”€ main.tf           # EC2 + provisioners
β”œβ”€β”€ scripts/
β”‚   └── welcome.sh    # πŸ“œ Sample script to copy
β”œβ”€β”€ terraform.tfvars  # Key name, private key path
└── TASK.md           # πŸ“ Your challenge (cloud-init, SSM, AMI)