Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.74 KB

README.md

File metadata and controls

59 lines (45 loc) · 1.74 KB

Terraform template example

This repository provides an example of using Terraform to provision infrastructure in Azure. The example is meant to serve as a template for people who are new to Terraform or looking for a simple example to get started with.

Prerequisites

To use this example, you need to have the following installed:

Usage

  1. Clone the repository
git clone https://github.com/Botvinnik94/terraform-example.git
  1. Authenticate to Azure CLI
az login
  1. Navigate to the repository directory
cd terraform-example/terraform
  1. Check and modify the configuration files if necessary:

    • main.tf contains the infrastructure definition.
    • variables.tf contains the variables used in the infrastructure definition.
    • vars/<env>.tfvars contains the actual variable value for each environment.
  2. Ensure that you have created the following resources in Azure (you can change the naming by modifying the backend names in main.tf):

    • Resource Group with the name botvinnik-tf-rg
    • Storage Account within that Resource group with the name botvinniktfstac
    • Container within that Storage Account with the name botvinnik-tf-cont
  3. Initialize Terraform

terraform init
  1. Plan the Terraform execution with the variable file for the target environment
terraform plan -var-file=vars/<env>.tfvars
  1. Apply the Terraform execution
terraform apply -var-file=vars/<env>.tfvars

Clean up

To destroy the resources created by Terraform, run:

terraform destroy