Local Provider


Learn how to use and run Terraform basic commands

  1. Create a directory called “my_first_run”
  2. Inside the directory create a file called “” with the following content
resource "local_file" "mario_local_file" {
    content  = "It's a me, Mario!"
    filename = "/tmp/who_is_it.txt"
  1. Run terraform init. What did it do?
  2. Run terraform plan. What Terraform is going to perform?
  3. Finally, run ‘terraform apply’ and verify the file was created


# Create a directory
mkdir my_first_run && cd my_first_run

# Create the file ''
cat << EOT >>
resource "local_file" "mario_local_file" {
    content  = "It's a me, Mario!"
    filename = "/tmp/who_is_it.txt"

# Run 'terraform init'
terraform init
# Running 'ls -la' you'll it created '.terraform' and '.terraform.lock.hcl'
# In addition, it initialized (downloaded and installed) the relevant provider plugins. In this case, the "hashicorp/local"

# Run 'terraform plan'
terraform plan
# It shows what Terraform is going to perform once you'll run 'terraform apply'

<< terraform_plan_output
Terraform will perform the following actions:

  # local_file.mario_local_file will be created
  + resource "local_file" "mario_local_file" {
      + content              = "It's a me, Mario!"
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "/tmp/who_is_it.txt"
      + id                   = (known after apply)

Plan: 1 to add, 0 to change, 0 to destroy.

# Apply (it's better to run without -auto-approve if you are new to Terraform)
terraform apply -auto-approve

ls /tmp/who_is_it.txt
# /tmp/who_is_it.txt