Terraform is an infrastructure-as-code software developed by HashiCorp. The software allows you to define, provision and manage infrastructure using a declarative configuration language called HCL (HashiCorp Configuration Language).
You can install Terraform on macOS using 2 different methods.
- Install Terraform using Homebrew.
- Download the binary package.

Table of Contents
Install Terraform using Homebrew
To install Terraform using Homebrew, follow the below steps.
Add the HashiCorp Homebrew repository
You can use the below command to add the HashiCorp repository to Homebrew.
pgulian@Mac ~ % brew tap hashicorp/tap
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:d9faa506c014dedc0b034a68103ba75c9a58242f4d6c67b6ca0f649c39602bcf
############################################################################################################### 100.0%
==> Pouring portable-ruby-3.3.7.arm64_big_sur.bottle.tar.gz
==> Auto-updated Homebrew!

Install Terraform using the brew command
After you have added the HashiCorp repository, you just need to run one command to install Terraform.
pgulian@Mac ~ % brew install hashicorp/tap/terraform
terraform 1.10.3 is already installed but outdated (so it will be upgraded).
==> Fetching hashicorp/tap/terraform
==> Downloading https://releases.hashicorp.com/terraform/1.10.5/terraform_1.10.5_darwin_arm64.zip
############################################################################################################### 100.0%
==> Upgrading hashicorp/tap/terraform
1.10.3 -> 1.10.5
🍺 /opt/homebrew/Cellar/terraform/1.10.5: 5 files, 84.6MB, built in 1 second
==> Running `brew cleanup terraform`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /opt/homebrew/Cellar/terraform/1.10.3... (5 files, 84.6MB)
Removing: /Users/pgulian/Library/Caches/Homebrew/terraform--1.10.3.zip... (25MB)
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/pgulian/Library/Caches/Homebrew/python@3.12--3.12.8... (15.6MB)
Removing: /Users/pgulian/Library/Logs/Homebrew/python@3.13... (2 files, 2KB)
pgulian@Mac ~ %

Download the binary package
The second method is to download the binary package. To do this, visit the Hashicorp website here and click Download.

You can navigate to your Downloads directory and extract the binary package. Next, change the directory into terraform_1.10.5_darwin_arm64 and move the terraform executable file to /usr/local/bin.
pgulian@Mac Downloads % ls terraform_1.10.5_darwin_arm64.zip
terraform_1.10.5_darwin_arm64.zip
pgulian@Mac Downloads % unzip terraform_1.10.5_darwin_arm64
Archive: terraform_1.10.5_darwin_arm64.zip
inflating: LICENSE.txt
inflating: terraform
pgulian@Mac Downloads %
pgulian@Mac Downloads %
pgulian@Mac Downloads % cd terraform_1.10.5_darwin_arm64
pgulian@Mac terraform_1.10.5_darwin_arm64 % sudo mv terraform /usr/local/bin
Password:
Sorry, try again.
Password:
pgulian@Mac terraform_1.10.5_darwin_arm64 % ls /usr/local/bin/terraform
/usr/local/bin/terraform
pgulian@Mac terraform_1.10.5_darwin_arm64 %

Confirm that Terraform is installed correctly
By running the terraform version command, you can confirm that Terraform is installed correctly.
pgulian@Mac ~ % /usr/local/bin/terraform version
Terraform v1.10.5
on darwin_arm64
pgulian@Mac ~ %

Generate a local file using Terraform and the local provider
After installing Terraform, I will generate a local file using Terraform and the local provider.
Write a configuration file
You need to create a configuration file. I have created the main.tf file and added the following content to it. In my example, I used the local provider. The local_file resource will generate a local file with the name specified in the filename argument and will contain the content specified in the content argument.
pgulian@Mac terra-repo % ls
main.tf
pgulian@Mac terra-repo % cat main.tf
resource "local_file" "hello" {
filename = "/Users/pgulian/terra-repo/hello.txt"
content = "Hello from the Terraform generated file"
}
pgulian@Mac terra-repo %

Initialize Terraform
After you have finished writing your configuration file, you need to initialize Terraform with the terraform init command. During this process, Terraform will download the provider and install it on the local machine.
pgulian@Mac terra-repo % terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/local...
- Installing hashicorp/local v2.5.2...
- Installed hashicorp/local v2.5.2 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
pgulian@Mac terra-repo %

Plan changes
The next step is to run the terraform plan command. This command helps you to preview the changes before applying them.
pgulian@Mac terra-repo % terraform plan
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
+ create
Terraform will perform the following actions:
# local_file.hello will be created
+ resource "local_file" "hello" {
+ content = "Hello from the Terraform generated file"
+ content_base64sha256 = (known after apply)
+ content_base64sha512 = (known after apply)
+ content_md5 = (known after apply)
+ content_sha1 = (known after apply)
+ content_sha256 = (known after apply)
+ content_sha512 = (known after apply)
+ directory_permission = "0777"
+ file_permission = "0777"
+ filename = "/Users/pgulian/terra-repo/hello.txt"
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if
you run "terraform apply" now.
pgulian@Mac terra-repo %

Apply the configuration
If you are happy with the generated plan, you need to apply it by running the terraform apply command.
pgulian@Mac terra-repo % terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
+ create
Terraform will perform the following actions:
# local_file.hello will be created
+ resource "local_file" "hello" {
+ content = "Hello from the Terraform generated file"
+ content_base64sha256 = (known after apply)
+ content_base64sha512 = (known after apply)
+ content_md5 = (known after apply)
+ content_sha1 = (known after apply)
+ content_sha256 = (known after apply)
+ content_sha512 = (known after apply)
+ directory_permission = "0777"
+ file_permission = "0777"
+ filename = "/Users/pgulian/terra-repo/hello.txt"
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
local_file.hello: Creating...
local_file.hello: Creation complete after 0s [id=5595f2cc190fc52db4d7c15939adb1ef821dfa19]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
pgulian@Mac terra-repo %

Confirm that the file hello.txt was created
After running the terraform apply command, you can confirm that the file hello.txt was created in the specified directory and that it has the correct content.
pgulian@Mac terra-repo % ls
hello.txt main.tf terraform.tfstate
pgulian@Mac terra-repo % cat hello.txt
Hello from the Terraform generated file% pgulian@Mac terra-repo %

Destroy the configuration
If you do not need to maintain the created file (deployed infrastructure), you can remove it with the terraform destroy command.
pgulian@Mac terra-repo % terraform destroy
local_file.hello: Refreshing state... [id=5595f2cc190fc52db4d7c15939adb1ef821dfa19]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
- destroy
Terraform will perform the following actions:
# local_file.hello will be destroyed
- resource "local_file" "hello" {
- content = "Hello from the Terraform generated file" -> null
- content_base64sha256 = "1qus2KPQO3tdeCPl7QqnzO9SRj59PcA4lt3MDuJ9ruI=" -> null
- content_base64sha512 = "JMSjf0IKjcrrxlGtuTlFpGqH+khYwvlJlV4hgEEL19Sups6wkOdPBz8R5szpV33Up8lH2FBsACHNBvjUMxvzFw==" -> null
- content_md5 = "1973158f0191822bdc7c64fa6a6f61f7" -> null
- content_sha1 = "5595f2cc190fc52db4d7c15939adb1ef821dfa19" -> null
- content_sha256 = "d6abacd8a3d03b7b5d7823e5ed0aa7ccef52463e7d3dc03896ddcc0ee27daee2" -> null
- content_sha512 = "24c4a37f420a8dcaebc651adb93945a46a87fa4858c2f949955e2180410bd7d4aea6ceb090e74f073f11e6cce9577dd4a7c947d8506c0021cd06f8d4331bf317" -> null
- directory_permission = "0777" -> null
- file_permission = "0777" -> null
- filename = "/Users/pgulian/terra-repo/hello.txt" -> null
- id = "5595f2cc190fc52db4d7c15939adb1ef821dfa19" -> null
}
Plan: 0 to add, 0 to change, 1 to destroy.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
local_file.hello: Destroying... [id=5595f2cc190fc52db4d7c15939adb1ef821dfa19]
local_file.hello: Destruction complete after 0s
Destroy complete! Resources: 1 destroyed.
pgulian@Mac terra-repo % cat hello.txt
cat: hello.txt: No such file or directory
pgulian@Mac terra-repo %

You can confirm that the infrastructure was destroyed by running the cat hello.txt command.

Great job. You have installed Terraform on your macOS and deployed infrastructure-as-code using it.
