Local Provisioners

Learn how to run commands locally within our Terraform configuration.

Working with local provisioners

Local or local-exec provisioners are used to run commands on the local machine where the Terraform CLI is. We can do a handful of things with local provisioners. Let’s consider three scenarios where local-exec provisioners shine:

  1. Passing environment variables into a resource we create: Let’s consider a scenario where we have some variables that we need for our EC2 instance. We can define these variables in our configuration file and then export them to the instance while creating it. A code snippet that exemplifies this is shown below.

Get hands-on with 1400+ tech skills courses.