---
title: "Orchestrating Infrastructure with Terraform"
lang: "en"
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/post/orchestrating-infrastructure-with-terraform
---

![Blog post image for Orchestrating Infrastructure with Terraform - Terraform lets you create and manage infrastructure across multiple cloud providers by writing declarative configuration files. This post covers how Terraform provisions AWS resources, from execution plans to state management and reusable modules.](/_astro/hero.D2PoOOZD_158qOe.webp)

[Home](/)›[Blog](/blog)›[All Categories](/blog/categories)›[Terraform](/blog/categories/terraform)

Blog

[Prev in TerraformModular Terraform for Scalable Infrastructure as Code](/blog/post/modular-terraform-scalable-iac-guide)[Next in TerraformStreamlining GitHub Organization Management with Terraform](/blog/post/streamlining-github-organization-management-with-terraform)

[Terraform](/blog/categories/terraform)[Infrastructure as Code](/blog/categories/infrastructure-as-code)[DevOps](/blog/categories/devops)[Cloud Provisioning](/blog/categories/cloud-provisioning)[AWS](/blog/categories/aws)

# Orchestrating Infrastructure with Terraform

[Mohammad Abu Mattar](/authors/mohammad-abu-mattar)Published: 22 May 202303 Mins read07 Mins listen

[Markdown for AI(opens in a new tab)](/post/orchestrating-infrastructure-with-terraform/index.md "Open the plain-Markdown version of this page, for pasting into an AI tool")

TL;DR

Terraform lets you create and manage infrastructure across multiple cloud providers by writing declarative configuration files. This post covers how Terraform provisions AWS resources, from execution plans to state management and reusable modules.

Series

[Infrastructure as Code Mastery](/series/infrastructure-as-code-mastery)6/8

[PreviousDeploying Serverless Applications with AWS SAM](/blog/post/deploying-serverless-applications-with-aws-sam)[NextBest Practices for Infrastructure Automation in a Cloud Native AWS Environment](/blog/post/best-practices-for-infrastructure-automation-in-a-cloud-native-aws-environment)

All posts in this series (8)

Blog8

1.  [Infrastructure Automation on AWS: CloudFormation, SAM, and Terraform for IaC](/blog/post/infrastructure-automation-on-aws-cloudformation-sam-and-terraform-for-iac)
2.  [Understanding Infrastructure as Code (IaC)](/blog/post/understanding-infrastructure-as-code-iac)
3.  [Cloud Native Infrastructure on AWS](/blog/post/cloud-native-infrastructure-on-aws)
4.  [AWS CloudFormation for Infrastructure as Code (IaC)](/blog/post/aws-cloudformation-for-infrastructure-as-code-iac)
5.  [Deploying Serverless Applications with AWS SAM](/blog/post/deploying-serverless-applications-with-aws-sam)
6.  [Orchestrating Infrastructure with TerraformYou are here](/blog/post/orchestrating-infrastructure-with-terraform)
7.  [Best Practices for Infrastructure Automation in a Cloud Native AWS Environment](/blog/post/best-practices-for-infrastructure-automation-in-a-cloud-native-aws-environment)
8.  [Navigating the Future of Cloud with Multi-Cloud IaC: Pulumi and Crossplane](/blog/post/multi-cloud-iac-pulumi-crossplane-future-cloud)

### Orchestrating Infrastructure with Terraform

Contents

[Introduction](#introduction)[How Terraform works](#how-terraform-works)[Infrastructure as Code](#infrastructure-as-code)[Declarative language](#declarative-language)[Terraform in action](#terraform-in-action)[Resource providers](#resource-providers)[Infrastructure configuration](#infrastructure-configuration)[Execution plans](#execution-plans)[Provisioning infrastructure](#provisioning-infrastructure)[Init and apply](#init-and-apply)[State management](#state-management)[Efficiency and collaboration](#efficiency-and-collaboration)[Infrastructure modules](#infrastructure-modules)[Version control and collaboration](#version-control-and-collaboration)[Extending with providers and modules](#extending-with-providers-and-modules)[Best practices for Terraform](#best-practices-for-terraform)[Infrastructure as Code principles](#infrastructure-as-code-principles)[Terraform workspaces](#terraform-workspaces)[Terraform Cloud and CI/CD integration](#terraform-cloud-and-cicd-integration)[Conclusion](#conclusion)[References](#references)

## [Introduction](#introduction)

Terraform is a tool for infrastructure orchestration that lets you create and manage infrastructure across multiple cloud providers. With Terraform, you provision resources on AWS by writing infrastructure configurations in a declarative language. This post covers how Terraform provisions infrastructure and the practices that make it reliable to use.

## [How Terraform works](#how-terraform-works)

### [Infrastructure as Code](#infrastructure-as-code)

Terraform is built on Infrastructure as Code (IaC), so you define and manage your infrastructure using code. Codifying your infrastructure configurations gives you reproducibility, scalability, and version control.

### [Declarative language](#declarative-language)

Terraform uses a declarative language called HashiCorp Configuration Language (HCL). This language lets you express your desired infrastructure state without specifying the detailed steps for achieving it; Terraform figures out the steps and orchestrates the provisioning process.

## [Terraform in action](#terraform-in-action)

### [Resource providers](#resource-providers)

Terraform supports various resource providers, including AWS, Azure, Google Cloud, and many more. With the AWS provider, you can provision AWS resources such as EC2 instances, S3 buckets, and VPCs.

### [Infrastructure configuration](#infrastructure-configuration)

Terraform uses configuration files called “Terraform files” to define your infrastructure. In these files, you specify the resources you want to create, their properties, and any dependencies between them. Terraform reads these files to work out the order of resource creation, then provisions everything in that order.

### [Execution plans](#execution-plans)

Before applying changes, Terraform generates an execution plan that outlines the actions it will take to achieve the desired infrastructure state. This plan lets you preview the changes, so you stay in control of the provisioning process.

## [Provisioning infrastructure](#provisioning-infrastructure)

### [Init and apply](#init-and-apply)

Terraform requires an initialization step to download the necessary provider plugins and set up the execution environment. Once initialized, you provision the defined infrastructure resources by running `terraform apply`.

### [State management](#state-management)

Terraform maintains a state file that keeps track of the current state of your infrastructure. This file lets Terraform see the differences between the desired state and the actual state, so it can make the changes needed to close the gap.

## [Efficiency and collaboration](#efficiency-and-collaboration)

### [Infrastructure modules](#infrastructure-modules)

Terraform allows you to create reusable modules, which are self-contained configurations that encapsulate a set of resources and their dependencies. These modules let you reuse code and keep your infrastructure consistent.

### [Version control and collaboration](#version-control-and-collaboration)

By treating Terraform configurations as code, you can store them in version control systems, which lets team members work together and gives you a history of changes. You also get proper code management and easy rollbacks.

### [Extending with providers and modules](#extending-with-providers-and-modules)

Terraform is extensible. You can pull in extra providers and modules to widen what it does. This flexibility lets you integrate with different cloud providers and use community-created modules for common infrastructure patterns.

## [Best practices for Terraform](#best-practices-for-terraform)

### [Infrastructure as Code principles](#infrastructure-as-code-principles)

Apply best practices of Infrastructure as Code, such as using version control, documenting changes, and reviewing code, to keep your Terraform configurations reliable and maintainable.

### [Terraform workspaces](#terraform-workspaces)

Use Terraform workspaces to manage different environments and keep separate state files. Workspaces let you deploy and manage development, testing, and production infrastructure independently.

### [Terraform Cloud and CI/CD integration](#terraform-cloud-and-cicd-integration)

Consider using Terraform Cloud or integrating Terraform into your CI/CD pipelines to automate the provisioning process, enforce policies, and enable collaboration within your infrastructure provisioning workflows.

## [Conclusion](#conclusion)

Terraform lets you create and manage infrastructure across multiple cloud providers with a consistent, repeatable workflow. By applying Infrastructure as Code principles and using Terraform’s declarative model, you can orchestrate your infrastructure reliably and with less manual effort.

## [References](#references)

1.  Terraform by HashiCorp - Official Website, [https://www.terraform.io/](https://www.terraform.io/)
2.  Terraform Documentation, [https://developer.hashicorp.com/terraform/docs](https://developer.hashicorp.com/terraform/docs)
3.  Terraform AWS Provider Documentation, [https://registry.terraform.io/providers/hashicorp/aws/latest/docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
4.  Infrastructure as Code - AWS, [https://aws.amazon.com/devops/infrastructure-as-code/](https://aws.amazon.com/devops/infrastructure-as-code/)
5.  HashiCorp Configuration Language (HCL.), [https://github.com/hashicorp/hcl](https://github.com/hashicorp/hcl)
6.  Terraform Modules - Terraform Documentation, [https://developer.hashicorp.com/terraform/language/modules](https://developer.hashicorp.com/terraform/language/modules)
7.  Terraform State Management - Terraform Documentation, [https://developer.hashicorp.com/terraform/language/state](https://developer.hashicorp.com/terraform/language/state)
8.  Terraform Workspaces - Terraform Documentation, [https://developer.hashicorp.com/terraform/language/workspaces](https://developer.hashicorp.com/terraform/language/workspaces)
9.  Terraform Cloud, [https://www.hashicorp.com/products/terraform](https://www.hashicorp.com/products/terraform)
10.  Best Practices for using Terraform - Gruntwork, [https://gruntwork.io/guides/foundations/how-to-use-terraform-effectively/](https://gruntwork.io/guides/foundations/how-to-use-terraform-effectively/)
11.  Getting Started with Terraform on AWS - AWS Workshop, [https://catalog.workshops.aws/terraform-beginner-to-pro/en-US](https://catalog.workshops.aws/terraform-beginner-to-pro/en-US)
12.  Terraform Registry (for providers and modules.), [https://registry.terraform.io/](https://registry.terraform.io/)

Was this useful?

## Tags

[#Terraform](/blog/tags/terraform)[#IaC](/blog/tags/iac)[#AWS Provisioning](/blog/tags/aws-provisioning)[#DevOps Tools](/blog/tags/devops-tools)[#HCL](/blog/tags/hcl)[#Infrastructure Automation](/blog/tags/infrastructure-automation)[#Cloud Management](/blog/tags/cloud-management)[#Terraform Modules](/blog/tags/terraform-modules)[#Terraform Best Practices](/blog/tags/terraform-best-practices)[#CI/CD for Infrastructure](/blog/tags/cicd-for-infrastructure)

## Share

[Facebook](https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform "Share on Facebook")[Twitter](https://twitter.com/intent/tweet/?text=Orchestrating%20Infrastructure%20with%20Terraform&url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform "Share on Twitter")[LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform&title=Orchestrating%20Infrastructure%20with%20Terraform&summary=Terraform%20lets%20you%20create%20and%20manage%20infrastructure%20across%20multiple%20cloud%20providers%20by%20writing%20declarative%20configuration%20files.%20This%20post%20covers%20how%20Terraform%20provisions%20AWS%20resources%2C%20from%20execution%20plans%20to%20state%20management%20and%20reusable%20modules.&source=https://mkabumattar.com "Share on LinkedIn")[WhatsApp](https://wa.me/?text=Orchestrating%20Infrastructure%20with%20Terraform%20https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform "Share on WhatsApp")[Telegram](https://t.me/share/url?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform&text=Orchestrating%20Infrastructure%20with%20Terraform "Share on Telegram")[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform&title=Orchestrating%20Infrastructure%20with%20Terraform "Share on Reddit")[Hacker News](http://news.ycombinator.com/submitlink?u=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform&t=Orchestrating%20Infrastructure%20with%20Terraform "Share on Hacker News")[Pinterest](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform&media=&description=Terraform%20lets%20you%20create%20and%20manage%20infrastructure%20across%20multiple%20cloud%20providers%20by%20writing%20declarative%20configuration%20files.%20This%20post%20covers%20how%20Terraform%20provisions%20AWS%20resources%2C%20from%20execution%20plans%20to%20state%20management%20and%20reusable%20modules. "Share on Pinterest")[Email](<mailto:?subject=Orchestrating%20Infrastructure%20with%20Terraform&body=Check out this article: https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Forchestrating-infrastructure-with-terraform>)

## Comments

## You might also enjoy

More posts on similar topics

[![Infrastructure Automation on AWS: CloudFormation, SAM, and Terraform for IaC](/_astro/hero.BsNJX0oJ_LxOfi.webp)](/blog/post/infrastructure-automation-on-aws-cloudformation-sam-and-terraform-for-iac)

## [Infrastructure Automation on AWS: CloudFormation, SAM, and Terraform for IaC](/blog/post/infrastructure-automation-on-aws-cloudformation-sam-and-terraform-for-iac)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [Infrastructure as Code](/blog/categories/infrastructure-as-code)
-   [Cloud Native](/blog/categories/cloud-native)
-   [DevOps](/blog/categories/devops)
-   [Automation](/blog/categories/automation)

Introduction This post covers Infrastructure as Code (IaC) and how it fits into a Cloud Native AWS environment: what IaC gives you, and how CloudFormation, AWS SAM, and Terraform each handle a dif

[#IaC](/blog/tags/iac)[#AWS CloudFormation](/blog/tags/aws-cloudformation)[#AWS SAM](/blog/tags/aws-sam)+6 tags

[read more](/blog/post/infrastructure-automation-on-aws-cloudformation-sam-and-terraform-for-iac)

[![Cloud Native Infrastructure on AWS](/_astro/hero.CwVzviwB_4akIX.webp)](/blog/post/cloud-native-infrastructure-on-aws)

## [Cloud Native Infrastructure on AWS](/blog/post/cloud-native-infrastructure-on-aws)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [Cloud Native](/blog/categories/cloud-native)
-   [Serverless](/blog/categories/serverless)
-   [DevOps](/blog/categories/devops)
-   [Infrastructure as Code](/blog/categories/infrastructure-as-code)

Introduction Cloud native infrastructure lets developers design and deploy applications built specifically for the cloud, rather than adapted to it. Using AWS services well, it enables application

[#Cloud Native Architecture](/blog/tags/cloud-native-architecture)[#AWS Services](/blog/tags/aws-services)[#AWS Lambda](/blog/tags/aws-lambda)+10 tags

[read more](/blog/post/cloud-native-infrastructure-on-aws)

[![AWS CloudFormation for Infrastructure as Code (IaC)](/_astro/hero.DW2mCCZ1_Z1qXfDg.webp)](/blog/post/aws-cloudformation-for-infrastructure-as-code-iac)

## [AWS CloudFormation for Infrastructure as Code (IaC)](/blog/post/aws-cloudformation-for-infrastructure-as-code-iac)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [CloudFormation](/blog/categories/cloudformation)
-   [Infrastructure as Code](/blog/categories/infrastructure-as-code)
-   [DevOps](/blog/categories/devops)
-   [Cloud Automation](/blog/categories/cloud-automation)

Introduction AWS CloudFormation is one of the core Infrastructure as Code (IaC) tools on AWS. It lets you declare your infrastructure using JSON or YAML templates, which simplifies creation and ma

[#AWS CloudFormation](/blog/tags/aws-cloudformation)[#IaC](/blog/tags/iac)[#JSON](/blog/tags/json)+7 tags

[read more](/blog/post/aws-cloudformation-for-infrastructure-as-code-iac)

[![Understanding Infrastructure as Code (IaC)](/_astro/hero.D6yb7pOQ_Z2ptmwB.webp)](/blog/post/understanding-infrastructure-as-code-iac)

## [Understanding Infrastructure as Code (IaC)](/blog/post/understanding-infrastructure-as-code-iac)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Infrastructure as Code](/blog/categories/infrastructure-as-code)
-   [DevOps](/blog/categories/devops)
-   [Cloud Computing](/blog/categories/cloud-computing)
-   [Automation](/blog/categories/automation)
-   [Software Engineering](/blog/categories/software-engineering)

Introduction Infrastructure as Code (IaC) manages infrastructure through code instead of manual configuration. Instead of clicking through consoles to set up servers, networks, and storage, you de

[#IaC](/blog/tags/iac)[#AWS CloudFormation](/blog/tags/aws-cloudformation)[#Terraform](/blog/tags/terraform)+7 tags

[read more](/blog/post/understanding-infrastructure-as-code-iac)

[![Deploying Serverless Applications with AWS SAM](/_astro/hero.CdyEyleP_2fYFz9.webp)](/blog/post/deploying-serverless-applications-with-aws-sam)

## [Deploying Serverless Applications with AWS SAM](/blog/post/deploying-serverless-applications-with-aws-sam)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [Serverless](/blog/categories/serverless)
-   [DevOps](/blog/categories/devops)
-   [Infrastructure as Code](/blog/categories/infrastructure-as-code)
-   [Application Deployment](/blog/categories/application-deployment)

Introduction AWS SAM (Serverless Application Model) extends AWS CloudFormation with a simpler syntax for defining and deploying serverless applications. SAM templates let you define and deploy you

[#AWS SAM](/blog/tags/aws-sam)[#Serverless Framework](/blog/tags/serverless-framework)[#AWS Lambda](/blog/tags/aws-lambda)+5 tags

[read more](/blog/post/deploying-serverless-applications-with-aws-sam)

[![Best Practices for Infrastructure Automation in a Cloud Native AWS Environment](/_astro/hero.CTyi0Kde_16WUz4.webp)](/blog/post/best-practices-for-infrastructure-automation-in-a-cloud-native-aws-environment)

## [Best Practices for Infrastructure Automation in a Cloud Native AWS Environment](/blog/post/best-practices-for-infrastructure-automation-in-a-cloud-native-aws-environment)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [Cloud Native](/blog/categories/cloud-native)
-   [DevOps](/blog/categories/devops)
-   [Infrastructure Automation](/blog/categories/infrastructure-automation)
-   [Best Practices](/blog/categories/best-practices)

Introduction Infrastructure automation is core to running a cloud native AWS environment well. This post covers the best practices for security and compliance, CI/CD pipelines, monitoring and scal

[#AWS Automation](/blog/tags/aws-automation)[#Infrastructure as Code (IaC)](/blog/tags/infrastructure-as-code-iac)[#CI/CD Pipelines](/blog/tags/cicd-pipelines)+7 tags

[read more](/blog/post/best-practices-for-infrastructure-automation-in-a-cloud-native-aws-environment)

6 related posts
