> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Guides setting up a local environment, tools, and authentication to develop, validate, and deploy Terraform configurations for provisioning Azure resources.

Setting up the environment

Before writing any Terraform code, prepare a consistent local environment. This section outlines the essential tools and steps to develop, validate, and apply Terraform configurations for Azure.

An IDE such as Visual Studio Code improves productivity by providing HCL syntax highlighting, validation, auto-completion, and formatting. These features help reduce errors and make it easier to maintain Terraform code as projects grow.

Terraform relies on external tools to authenticate and communicate with Azure—most importantly, the Azure CLI.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/9l60TCpe5-axPZIp/images/Terraform-On-Azure/Setting-up-environment/Introduction/terraform-configuration-development-introduction.jpg?fit=max&auto=format&n=9l60TCpe5-axPZIp&q=85&s=ee5c78cb25b9679d13a0ecc60ee23026" alt="The image is an introduction slide detailing steps for developing Terraform configurations, including selecting an IDE and installing dependencies for Azure." width="1920" height="1080" data-path="images/Terraform-On-Azure/Setting-up-environment/Introduction/terraform-configuration-development-introduction.jpg" />
</Frame>

Installing these dependencies enables Terraform to securely connect to Azure subscriptions and manage resources without manual intervention.

Finally, the Terraform CLI is the primary tool used to initialize configurations, validate HCL, generate execution plans, and apply changes. Verify the CLI installation before proceeding with hands-on exercises.

## Required tools and quick checks

Use the table below to confirm the primary tools and common verification commands:

| Tool                              | Purpose                                              | Verify                      |
| --------------------------------- | ---------------------------------------------------- | --------------------------- |
| Visual Studio Code (or other IDE) | Edit HCL, linting, formatting                        | `code --version`            |
| Azure CLI                         | Authenticate and manage Azure subscriptions          | `az --version`              |
| Terraform CLI                     | Initialize, plan, and apply infrastructure           | `terraform version`         |
| Optional extensions               | VS Code Terraform extension, Azure Account extension | Check VS Code extensions UI |

Install links:

* [Terraform downloads](https://www.terraform.io/downloads)
* [Azure CLI installation](https://learn.microsoft.com/cli/azure/install-azure-cli)
* [Visual Studio Code](https://code.visualstudio.com/)

## Install and verify

Install the Azure CLI and Terraform CLI, then confirm they are available in your PATH:

```bash theme={null}
# Verify Azure CLI
az --version

# Verify Terraform CLI
terraform version

# Verify VS Code (if installed)
code --version
```

If any command fails, follow the corresponding installation guide linked above and re-run the verification commands.

## Authenticate to Azure

After installing the Azure CLI, authenticate so Terraform can operate against your Azure subscription. Common authentication methods include:

* Interactive login (local development):

```bash theme={null}
az login
```

* Service principal (recommended for automation / CI pipelines):

```bash theme={null}
az ad sp create-for-rbac --name "tf-sp-automation" --role Contributor --scopes /subscriptions/<SUBSCRIPTION_ID>
# This command prints the appId, password, tenant - store these securely as pipeline secrets
```

* Managed identity (when Terraform runs from Azure-hosted compute)

<Callout icon="lightbulb" color="#1CB2FE">
  Common authentication options include interactive `az login` for local development, a service principal for automated pipelines, and managed identities when running from Azure-hosted compute.
</Callout>

Choose the method that matches your workflow and security requirements. For CI/CD, use a service principal with least-privilege role assignments and store credentials in your pipeline secret store.

## Quick Terraform workflow

Once tools are installed and authentication is configured, the typical Terraform workflow for Azure is:

1. Write HCL configuration files (.tf)
2. Initialize the working directory:

```bash theme={null}
terraform init
```

3. Preview changes:

```bash theme={null}
terraform plan -out=tfplan
```

4. Apply changes:

```bash theme={null}
terraform apply "tfplan"
```

Use `terraform validate` and `terraform fmt` to ensure code quality before planning and applying.

## Next steps

With your environment configured and authentication in place, proceed to create a simple Terraform configuration that provisions a resource group and a storage account. Refer to the official Terraform Azure Provider documentation for resource examples and provider configuration:

* [Terraform Azure Provider docs](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs)
* [Azure CLI documentation](https://learn.microsoft.com/cli/azure/)

This prepares you for the hands-on modules where we’ll initialize a Terraform project, configure the AzureRM provider, and deploy basic infrastructure.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/terraform-on-azure/module/db2adc19-fa48-4b03-9d9a-8ef71c4c28db/lesson/869116c0-840a-47cd-88cd-e91431d2016e" />
</CardGroup>
