Preparing Terraform
Before creating the Terraform configuration and code for the Kubernetes cluster, you need to create a new source code repository for the infrastructure and then create the Terraform directory structure. In addition to that, you will learn how to configure and use Terraform's shared state, which is an essential best practice for managing IaC in production environments.
Terraform directory structure
The Terraform directory is where all the Terraform source code lives in your source code repository. I recommend creating a separate source code repository. This repository should contain all the infrastructure code and configuration. The following is the directory structure of the Terraform source code that we will develop in the forthcoming sections:
Persisting the Terraform state
Terraform stores the state of the infrastructure resources under its management to be able to map it...