[DevOps]Infrastructure Provisioning (IaC) — Terraform, what is it, the basics, and what you should know.

Tonytruong
4 min readDec 29, 2022

--

Terraform is an open-source infrastructure as code software tool that enables you to define and manage infrastructure resources in a safe, efficient, and predictable manner. It can be used to manage resources on various infrastructure platforms, including public clouds (such as AWS, Azure, and Google Cloud), on-premises environments, and third-party services.

With Terraform, you can use configuration files written in the HashiCorp Configuration Language (HCL) to define your infrastructure resources and their dependencies. You can then use the Terraform CLI to create, update, and destroy those resources.

Terraform is designed to be easy to use, yet powerful enough to manage complex infrastructure. It supports a wide range of resource types and providers and allows you to use modules to create reusable components and improve organization. It also has features such as variables, outputs, and workspaces to help you manage your infrastructure more efficiently.

Overall, Terraform is a useful tool for automating the provisioning and management of infrastructure resources and can help you save time and reduce the risk of errors when working with complex infrastructure environments.

The Basics

These are what I believe to be a good list to start off familiarizing yourself with when you’re first starting out with Terraform. Don’t expect to know everything right away, use the list to supplement your own learning.

Infrastructure as code: Terraform allows you to define your infrastructure using configuration files written in the HashiCorp Configuration Language (HCL). This allows you to manage your infrastructure in a version control system and automate the provisioning and management of resources.

Resources: A resource is a unit of infrastructure, such as an Amazon Web Services (AWS) EC2 instance or an Azure virtual machine. Terraform supports a wide range of resources and providers.

Providers: A provider is a plugin for Terraform that allows it to interact with a specific cloud or on-premises infrastructure platform, such as AWS or Azure.

Modules: A module is a container for multiple resources that are used together. Modules can be used to create reusable components and improve organization.

Variables: Variables allow you to define reusable values in your configuration that can be passed as inputs to your resources and modules.

Outputs: Outputs are values that are returned by a resource or module and can be used by other resources or modules.

State: Terraform maintains a state file that tracks the resources that have been created. This state is used to determine what actions are necessary when you make changes to your infrastructure.

Workspaces: Workspaces allow you to manage multiple sets of infrastructure resources within the same configuration. This can be useful for environments such as staging and production.

Provisioners: Provisioners are scripts or other tools that are used to configure and install software on resources after they are created.

Terraform Cloud: Terraform Cloud is a cloud-based service provided by HashiCorp that allows you to store your Terraform state remotely, collaborate with team members, and use Terraform in a more production-like environment

How can you start?

  1. Install Terraform: You can download and install the Terraform CLI from the HashiCorp website or use a package manager such as Homebrew or Chocolatey.
  2. Set up an account on a cloud platform: In order to use Terraform to manage resources on a cloud platform, you will need to set up an account on a platform such as AWS, Azure, or Google Cloud. You will also need to create an access key and secret access key to use with Terraform.
  3. Read the documentation: HashiCorp provides comprehensive documentation on Terraform, including a tutorial and a reference guide. This is a good starting point to get an overview of the tool and its capabilities.
  4. Explore the provider documentation: Each provider has its own documentation that provides details on the resources and features available for that provider. This is a good resource to refer to when working with specific resources or features.
  5. Write some configuration files: You can start by writing simple configuration files to create and manage resources on a cloud platform. You can try creating different resource types and experimenting with different configuration options.
  6. Use modules: Modules can be used to create reusable components and improve organization. You can try writing your own modules or using modules from the Terraform Registry or other sources.
  7. Practice and learn from others: The best way to learn Terraform is to practice using it and learn from others. You can find a wealth of resources online, including blogs, tutorials, and community forums, where you can ask questions and learn from others who are using Terraform.

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

--

--

Tonytruong

DevOps Fanatic with a penchant to automate anything and everything — Terraform Nerd, Docker practitioner and self proclaimed AWS guru.