Skip to content

Sample Terraform templates for deploying and managing Azure resources. These templates are meant to serve as examples and should be adjusted as needed to fit specific use cases or requirements.

License

Notifications You must be signed in to change notification settings

MicrosoftCloudEssentials-LearningHub/AzureTerraformTemplates-v0.0.0

Repository files navigation

Azure Terraform Sample Templates: Version 0.0.0

Costa Rica

GitHub brown9804

Last updated: 2025-03-27


This repository is part of a series of repositories, with each repository dedicated to a specific version. This repository focuses exclusively on version 0.0.0. This is the initial version of the template, showcasing sample Terraform templates for deploying and managing Azure resources. These templates are provided as starting points and should be customized to meet your specific requirements and use cases.

List of References (Click to expand)

Templates available

Core Infrastructure (Click to expand)
Storage and Databases (Click to expand)

Prerequisites

  • An Azure subscription is required. All other resources, including instructions for creating a Resource Group, are provided in this repository. - Contributor role assigned or any custom role that allows: access to manage all resources, and the ability to deploy resources within subscription.
  • If you choose to use the Terraform approach, please ensure that:

Versioning

Version Description
0.0.0 This is the initial version of the template, showcasing sample configurations.
0.1.0 Added support for additional Azure services.
1.0.0 First stable release with a comprehensive set of Azure resources.

Overview

Templates structure:

.
├── README.md
├────── main.tf
├────── variables.tf
├────── provider.tf
├────── terraform.tfvars
├────── outputs.tf
  • main.tf (Main Terraform configuration file): This file contains the core infrastructure code. It defines the resources you want to create, such as virtual machines, networks, and storage. It's the primary file where you describe your infrastructure in a declarative manner.
  • variables.tf (Variable definitions): This file is used to define variables that can be used throughout your Terraform configuration. By using variables, you can make your configuration more flexible and reusable. For example, you can define variables for resource names, sizes, and other parameters that might change between environments.
  • provider.tf (Provider configurations): Providers are plugins that Terraform uses to interact with cloud providers, SaaS providers, and other APIs. This file specifies which providers (e.g., AWS, Azure, Google Cloud) you are using and any necessary configuration for them, such as authentication details.
  • terraform.tfvars (Variable values): This file contains the actual values for the variables defined in variables.tf. By separating variable definitions and values, you can easily switch between different sets of values for different environments (e.g., development, staging, production) without changing the main configuration files.
  • outputs.tf (Output values): This file defines the output values that Terraform should return after applying the configuration. Outputs are useful for displaying information about the resources created, such as IP addresses, resource IDs, and other important details. They can also be used as inputs for other Terraform configurations or scripts.

How to execute it

graph TD;
    A[az login] --> B(terraform init)
    B --> C{Terraform provisioning stage}
    C -->|Review| D[terraform plan]
    C -->|Order Now| E[terraform apply]
    C -->|Delete Resource if needed| F[terraform destroy]
Loading

Important

Please modify terraform.tfvars with your information, then run the following flow. If you need more visual guidance, please check the video that illustrates the provisioning steps.

  1. Login to Azure: This command logs you into your Azure account. It opens a browser window where you can enter your Azure credentials. Once logged in, you can manage your Azure resources from the command line.

    cd {to-the-template-resource-folder}
    az login
    img img
  2. Initialize Terraform: Initializes the working directory containing the Terraform configuration files. It downloads the necessary provider plugins and sets up the backend for storing the state.

    terraform init
    img
  3. Terraform Provisioning Stage:

    • Review: Creates an execution plan, showing what actions Terraform will take to achieve the desired state defined in your configuration files. It uses the variable values specified in terraform.tfvars.

      terraform plan -var-file terraform.tfvars
      Screenshot 2025-03-18 145143
    • Order Now: Applies the changes required to reach the desired state of the configuration. It prompts for confirmation before making any changes. It also uses the variable values specified in terraform.tfvars.

      terraform apply -var-file terraform.tfvars
      image
    • Remove: Destroys the infrastructure managed by Terraform. It prompts for confirmation before deleting any resources. It also uses the variable values specified in terraform.tfvars.

      terraform destroy -var-file terraform.tfvars
      image

Total Visitors

Visitor Count

About

Sample Terraform templates for deploying and managing Azure resources. These templates are meant to serve as examples and should be adjusted as needed to fit specific use cases or requirements.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages