Using Local-exec Provisioner in Terraform
📖 Scenario: You are setting up a simple cloud server using Terraform. After the server is created, you want to run a local script on your machine to notify you that the server is ready.
🎯 Goal: Build a Terraform configuration that creates a resource and uses the local-exec provisioner to run a local command after resource creation.
📋 What You'll Learn
Create a Terraform resource block for a null resource named
exampleAdd a
local-exec provisioner inside the resourceConfigure the provisioner to run the exact command
echo Server is readyEnsure the Terraform configuration is valid and deployable
💡 Why This Matters
🌍 Real World
Local-exec provisioners are useful for running scripts or commands on your local machine after cloud resources are created, such as sending notifications or updating local files.
💼 Career
Understanding provisioners helps cloud engineers automate deployment workflows and integrate Terraform with other tools and scripts.
Progress0 / 4 steps