Terraform Cookbook
Mikael Krief
- 366 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Terraform Cookbook
Mikael Krief
About This Book
Discover how to manage and scale your infrastructure using Infrastructure as Code (IaC) with Terraform
Key Features
- Get up and running with the latest version of Terraform, v0.13
- Design and manage infrastructure that can be shared, tested, modified, provisioned, and deployed
- Work through practical recipes to achieve zero-downtime deployment and scale your infrastructure effectively
Book Description
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.
What you will learn
- Understand how to install Terraform for local development
- Get to grips with writing Terraform configuration for infrastructure provisioning
- Use Terraform for advanced infrastructure use cases
- Understand how to write and use Terraform modules
- Discover how to use Terraform for Azure infrastructure provisioning
- Become well-versed in testing Terraform configuration
- Execute Terraform configuration in CI/CD pipelines
- Explore how to use Terraform Cloud
Who this book is for
This book is for developers, operators, and DevOps engineers looking to improve their workflow and use Infrastructure as Code. Experience with Microsoft Azure, Jenkins, shell scripting, and DevOps practices is required to get the most out of this Terraform book.
]]>
Frequently asked questions
Information
- Creating a Terraform module and using it locally
- Using modules from the public registry
- Sharing a Terraform module using GitHub
- Using another file inside a custom module
- Using the Terraform module generator
- Generating module documentation
- Using a private Git repository for sharing Terraform modules
- Applying a Terrafile pattern for using modules
- Testing Terraform module code with Terratest
- Building CI/CD for Terraform modules in Azure Pipelines
- Building a workflow for Terraform modules using GitHub Actions
Technical requirements
- To have Node.js and NPM installed on your computer: The download website is here: https://nodejs.org/en/.
- To have a GitHub account: If you don't have one, the creation of the account is free and can be done here: https://github.com/.
- To have an Azure DevOps organization: You can create one with a Live or GitHub account here: https://azure.microsoft.com/en-in/services/devops/.
- To have a basic knowledge of Git commands and workflow: The documentation is available here: https://git-scm.com/doc.
- To know about Docker: The documentation is here: https://docs.docker.com/.
- To install Golang on our workstation: The documentation is here: https://golang.org/doc/install. We will see the main steps of its installation in the Testing a Terraform module using Terratest recipe.
Creating a Terraform module and using it locally
Getting ready
How to do itâŠ
- In a new folder called moduledemo, create the Modules and webapp folders.
- In the webapp folder, create a new variables.tf file with the following code:
variable "resource_group_name" {
description = "Resource group name"
}
variable "location" {
description = "Location of Azure resource"
default = "West Europe"
}
variable "service_plan_name" {
description = "Service plan name"
}
variable "app_name" {
description = "Name of application"
}
- Then, create the main.tf file with the following code:
resource "azurerm_app_service_plan" "plan-app" {
name = var.service_plan_name
...