2. Terraform Installation and Setup
Machindranath wagare
Consultant at Atos | AWS, Azure | Git, Jenkins | Dynatrace, Datadog, ELK | Docker, Kubernetes and Security Focus
After going through the first article "Introduction to Terraform", here is the next following article on brief guide on how to install and set up Terraform.
Terraform installation is very easy and similar to many applications, rather after installation of Terraform we need to follow some steps to make its use. I will list the steps which you can follow along and start learning the Terraform by doing hands on.
Download Terraform:
You can download Terraform from the official website of Hashicorp. Terraform is distributed as a binary package, and you can also install it using popular package managers.
Install Terraform:
After downloading Terraform, find the appropriate package for your system and download it as a zip archive. Unzip the package and Terraform runs as a single binary named terraform. Any other files in the package can be safely removed and Terraform will still function. Finally, make sure that the terraform binary is available on your PATH. This process will differ depending on your operating system.
Verify the installation:
Verify that the installation worked by opening a new terminal session and listing Terraform’s available subcommands. It will show you main commands as shown in result below.
$ terraform -help
Or you can also verify Terraform Installation with following version command,
$ terraform -v
Now, you can confirm that you have successfully installed Terraform on your system. Next steps will guide you to initiate your work on the project [We will understand following all the steps one by one in our upcoming articles].
Configure Terraform:
Once Terraform is installed, you need to configure it to work with your cloud provider. You can do this by creating a configuration file in HashiCorp Configuration Language (HCL) [We will understand that in our upcoming articles]. The configuration file specifies the resources you want to create and manage, as well as the provider you want to use. You can find examples of configuration files in the Terraform documentation.
领英推荐
Once you complete your configuration step then -
Initialize the working directory:
After creating the configuration file, you need to initialize the working directory. This step downloads the provider and sets up the backend. Before running init command make sure you are in the same directory where your configuration file is placed.
$ terraform init
Create and apply the configuration:
Once the working directory is initialized, you can create and apply the configuration.
$ terraform apply
Destroy the infrastructure:
If you want to destroy the infrastructure, you can use the terraform destroy command. This command removes all the resources created by Terraform.
I hope this helps you get started with Terraform. Let me know if you have any further questions!
Terraform Get Started Documentation: AWS | Terraform | HashiCorp Developer
Terraform Official Registry: Terraform Registry
Follow me on LinkedIn: Machindranath wagare | LinkedIn