- A collection of Hands-on labs for Terraform.
- Each lab is a standalone lab and does not require to complete the previous labs.
This tutorial will walk you using terraform locally without any requirements for any cloud provider.
If you are using GCP all the tools are pre-installed
Terraform | Kubernetes | Minikube | Helm | kubectl |
---|---|---|---|---|
Tool | Comments |
---|---|
K8S | An existing cluster or any other local tool as described here |
kubectl | The Kubernetes command-line tool, kubectl |
minikube | Local cluster for running the hands on labs |
Helm | Some of the demos will require helm charts installed |
Terraform | This is what this tutorial is about ... |
- IAC - Infrastructure As Code
- Open Source developed by HashiCorp
- Declarative language - Define what you want and terraform will "get" there, terraform will figure out how to create what you wish.
- Terraform is mainly for Infrastructure (IAC)
- Terraform is based upon modules
-
- Infrastructure is described using a high-level configuration syntax with HCL files.
- Due to the fact that HCL are text files they can be stores in SCM (GIT for example) in a branch level, this ability allow to share, reuse, versioned and more.
-
terraform plan
generates an execution plan (JSON file).- Since this a text file (JSON) as mentioned above it can be stored in SCM (GIT for example) and can versioned, shared and more.
- The execution plan calculate the "difference" between the current state to the desired state.
- The plan describe exactly what
Terraform
will change and in what order which make it clear what will happen.
-
-
Terraform builds a graph of all your resources.
-
Terraform try to execute the required changes in parallel of any non-dependent resources.
-
terraform graph
generate aDOT
(DOT is a graph description language) files which can be converted tosvg
images for example. -
# Generate a graph based upon the execution plan # require dot to be installed, ### MacOs brew install graphviz ### Linux sudo apt-get install graphviz terraform graph | dot -Tsvg > graph.svg
-
-
- Terraform as
IAC
(Infrastructure as code) tool, and as such it designed for making automated changes or with a minimal human interaction. - Terraform support using templates for re-use code. In this way we it support multiple environments, providers by writing a simple syntax.
- Terraform as
- Terraform is build upon 2 main components:
- Core
- State
- User write the desired code, terraform calculate the desired result and execute it using the selected provider.
- In the following labs we will learn how to work with Terraform
- List of the labs in this repository:
📗 00-Setup
📗 01-init
📗 02-get
📗 03-validate
📗 04-plan
📗 05-apply
📗 06-destroy
📗 07-refresh
📗 09-import
📗 10-state
📗 11-workspace
📗 12-graph
📗 02-Variables
📗 03-Getting-Started-Kubernetes
📗 04-Getting-Started-Helm-Chart
- 01. A bit about
init
- 02.
terraform init -backend
- 03.
terraform init -get -upgrade
- 04. Working with plugins
- 05. Hands-On
©CodeWizard LTD