Book description
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.
Table of contents
- Title Page
- Copyright and Credits
- Foreword
- Dedication
- About Packt
- Contributors
- Preface
-
Setting Up the Terraform Environment
- Technical requirements
- Downloading and installing Terraform manually
- Installing Terraform using a script on Linux
- Installing Terraform using a script on Windows
- Executing Terraform in a Docker container
- Writing Terraform configuration in VS Code
- Migrating your Terraform configuration to Terraform 0.13
-
Writing Terraform Configuration
- Technical requirements
- Configuring Terraform and the provider version to use
- Manipulating variables
- Using local variables for custom functions
- Using outputs to expose Terraform provisioned data
- Provisioning infrastructure in multiple environments
- Obtaining external data with data sources
- Using external resources from other state files
- Querying external data with Terraform
- Calling Terraform built-in functions
- Writing conditional expressions
- Manipulating local files with Terraform
- Executing local programs with Terraform
- Generating passwords with Terraform
- Building Dynamic Environments with Terraform
-
Using the Terraform CLI
- Technical requirements
- Keeping your Terraform configuration clean
- Validating the code syntax
- Destroying infrastructure resources
- Using workspaces for managing environments
- Importing existing resources
- Exporting the output in JSON
- Tainting resources
- Generating the graph dependencies
- Debugging the Terraform execution
-
Sharing Terraform Configuration with Modules
- Technical requirements
- 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 a Terraform module
- 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
-
Provisioning Azure Infrastructure with Terraform
- Technical requirements
- Using Terraform in Azure Cloud Shell
- Protecting the Azure credential provider
- Protecting the state file in the Azure remote backend
- Executing ARM templates in Terraform
- Executing Azure CLI commands in Terraform
- Using Azure Key Vault with Terraform to protect secrets
- Getting a list of Azure resources in Terraform
- Provisioning and configuring an Azure VM with Terraform
- Building Azure serverless infrastructure with Terraform
- Generating a Terraform configuration for existing Azure infrastructure
-
Deep Diving into Terraform
- Technical requirements
- Creating an Ansible inventory with Terraform
- Testing the Terraform configuration using kitchen-terraform
- Preventing resources from getting destroyed
- Zero-downtime deployment with Terraform
- Detecting resources deleted by the plan command
- Managing Terraform configuration dependencies using Terragrunt
- Using Terragrunt as a wrapper for Terraform
- Building CI/CD pipelines for Terraform configurations in Azure Pipelines
- Working with workspaces in CI/CD
-
Using Terraform Cloud to Improve Collaboration
- Technical requirements
- Using the remote backend in Terraform Cloud
- Using Terraform Cloud as a private module registry
- Executing Terraform configuration remotely in Terraform Cloud
- Automating Terraform Cloud using APIs
- Testing the compliance of Terraform configurations using Sentinel
- Using cost estimation for cloud cost resources governance
- Other Books You May Enjoy
Product information
- Title: Terraform Cookbook
- Author(s):
- Release date: October 2020
- Publisher(s): Packt Publishing
- ISBN: 9781800207554
You might also like
book
Terraform Cookbook
Cloud services and SaaS software permeate every company's IT landscape, requiring a shift from manually provisioned …
book
Terraform: Up and Running, 3rd Edition
Terraform has become a key player in the DevOps world for defining, launching, and managing infrastructure …
book
Kubernetes: Up and Running, 3rd Edition
This third edition comes with a dedicated playlist of interactive Katacoda labs mapped to each section …
video
Kubernetes for the Absolute Beginners - Hands-On
Starting from the fundamental concept of containers, the course gradually unfolds into a comprehensive guide on …