In this blog, I write how to install Terraform for Mac and get started using it.
- Install Terraform on Mac
- Verify that Terraform is installed
- Basic commands of Terraform
1. Install Terraform on Mac
To install, run the following two commands:
% brew tap hashicorp/tap
% brew install hashicorp/tap/terraform
But for my Mac, I got the following error message.
Error: No developer tools installed.
Install the Command Line Tools:
xcode-select --install
Error: 'git' must be installed and in your PATH!
By installing xcode and git, I was able to fix the error message.
% xcode-select --install
% brew install git
2. Verify that Terraform is installed
Now I may have managed to get Terraform to install completely.
So I need to check if this is the case with the following commands.
% terraform --version
Terraform v1.3.7
on darwin_arm64
3. Basic commands of Terraform
- Initialise Terraform You need to initialise Terraform before using it.
% terraform init
Terraform initialized in an empty directory!
- Check the status of Terraform To check the current status of your infrastructure resources, use the following command I get an error because I have nothing configured at the moment.
% terraform plan
│ Error: No configuration files
- Apply Terraform Apply Terraform to make changes to the infrastructure.
% terraform apply
│ Error: No configuration files
- Deleting Terraform You can use the following commands to delete an infrastructure resource.
% terraform destroy
- Managing Terraform Status You can use the following commands to check and manage your current state.
% terraform state list
% terraform state show <resource_name>
% terraform state mv <resource_name> <new_name>
% terraform state pull
% terraform state push
I have nothing to configure at the moment. I will use these commands when I create my infrastructure resource.
Top comments (0)