Book Image

Terraform Cookbook

By : Mikael Krief
Book Image

Terraform Cookbook

By: Mikael Krief

Overview of this book

HashiCorp Configuration Language (HCL) has changed how we define and provision a data center infrastructure with the launch of Terraform—one of the most popular and powerful products for building Infrastructure as Code. This practical guide will show you how to leverage HashiCorp's Terraform tool to manage a complex infrastructure with ease. Starting with recipes for setting up the environment, this book will gradually guide you in configuring, provisioning, collaborating, and building a multi-environment architecture. Unlike other books, you’ll also be able to explore recipes with real-world examples to provision your Azure infrastructure with Terraform. Once you’ve covered topics such as Azure Template, Azure CLI, Terraform configuration, and Terragrunt, you’ll delve into manual and automated testing with Terraform configurations. The next set of chapters will show you how to manage a balanced and efficient infrastructure and create reusable infrastructure with Terraform modules. Finally, you’ll explore the latest DevOps trends such as continuous integration and continuous delivery (CI/CD) and zero-downtime deployments. By the end of this book, you’ll have developed the skills you need to get the most value out of Terraform and manage your infrastructure effectively.
Table of Contents (10 chapters)

Downloading and installing Terraform manually

In this recipe, we will learn how to download and install Terraform on a local machine under a Windows operating system.

Getting ready

To complete this recipe, the only prerequisite is that you're on a Windows operating system.

How to do it…

Perform the following steps:

  1. Open Windows File Explorer. Choose a location and create a folder called Terraform. We will use this to store the Terraform binary; for example, C:/Terraform.
  2. Launch a web browser and go to https://www.terraform.io/downloads.html.
  3. Scroll down the page until you reach the package for Windows:
  1. Click on the 64-bit link, which targets the Terraform ZIP package for the Windows 64-bit operating system. The package will be downloaded locally.
  2. Unzip the content of the downloaded ZIP file into the Terraform folder that we created in step 1:

The last thing we need to do to install Terraform is configure the Path environment variable by adding the path of the Terraform...