Terraform - Introduction
Terraform is a tool for automating infrastructure dpeloyments. It allows you to create, destroy, and update infrastructure. It is mainly used for managing cloud infrastructure and resources such as AWS, Azure, Docker, Kubernetes, KVM, and more. It is a speciallized tool that is geared towards infrastructure provisioning. It overlaps with other tools such as Ansible but these tools generally have separate roles. For example, Terraform is great for provisioning cloud hosts while Ansible is great for provisioning and configuring the applications that are run on those hosts. Two tools like Terraform and Ansible are often used together but for different purposes even though their functionality does overlap in some areas.
This page is part of a series. Keep reading the other sections for detailed instructions on how to setup and use Terraform.
Features / Key Points:
- Infrastructure as code (IaC) tool
- Multiple cloud platforms
- Declarative
- “safe, consistent, and repeatable”
- “version, reuse, and share”
- Can use with version control like git
Terraform is an infrastructure as code tool ( IaC ). The concept with this is that all infrastructure is defined as code. Instead of manually creating and configuring infrastructure, you would write a configuration file that defines what that infrastructure should look like. Terraform uses this configuration or code to actually manage the state of thatt infrastructure, creating and destroying as needed.
Terraform is declarative. That means that we don’t define what actions should be taken to setup servers and infrastructure. We just define the expected state of the infrastructure in a delarative manner. Terrform will then ensure that the state of the infrastructure matches what has been defined.
It supports multiple cloud platforms including AWS, Azure, GCP, and more. It supports more platforms than you would probably even be able to list off of the top of your head. This is done through the use of plugins, called “providers”. If a provider doesn’t exist for a given platform, it can be created.
Since infrastructure is based on code, that code can be controlled using a version control system such as GIT. This allows infrastructure definitions to be versioned. It also alows configurations to be shared and reused to recreate the same infractructure again and again.
Some terms to start:
- providers - plugins to work with cloud platforms and services
- Terraform registry
- Resources - units of infrastructure
- Modules
- State file
Providers are basically plugins that work with different cloud platforms and services. The Terraform registry is basically a centralized repository of different providers that have already been created and tested. These can easily be pulled down and used by anyone using Terraform.
Resources are just units of infrastructure. These could be servers / virtual machines, containers, storage, NICs, networks, users, groups, and just about anything else that you could define. Modules are sets of infrastructure that have been grouped together.
Terraform keeps the known state of infractructure in a state file.