Skip to content

IaC Deployment Pipeline

This lab will walk through onboarding and running Terraform according to standards, including execution in multiple environments inside an ADO pipeline using infrastructure as code (IaC).

Estimated time to complete: 5 hours


Overview

Using the learning from the Terraform Primer lab, you will modernize, onboard, and execute Terraform according to standards with TFE, modules, and ADO pipelines.

  • Real-world look and hands-on approach to building IaC pipelines at
  • Abstract vanilla Terraform into approved modules
  • Run Terraform from ADO Pipelines
  • Use approved pipeline templates
  • Manage infrastructure on two workspaces and environments (dev and model)

Standards

The standards and guidelines for IaC deployment pipelines are defined and regularly updated at this confluence page: IaC Onboarding

Requirements

Begin the development workflow

  • Continue using the same work item and branch from the Terraform Primer, otherwise create a new ticket under the Terraform lab feature.
  • Ensure you have pushed up your existing code to ADO Repos

You will continue using the completed Terraform code from the Terraform Primer lab. If you did not complete that lab or were unable to successfully finish, use the solution code below.

Completed code from Terraform Primer lab
terraform {
  backend "remote" {
    workspaces {
      name = "dojo-terraform-workshop-dev"
    }
    hostname     = "tfe.com"
    organization = "Corporate-Functions"
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_app_service" "dojo_app_service" {
  name                = var.app_service_name
  location            = var.location
  resource_group_name = var.resource_group_name
  app_service_plan_id = azurerm_app_service_plan.dojo_appservice_plan.id

  site_config {
    dotnet_framework_version = "v4.0"
    remote_debugging_enabled = "true"
    remote_debugging_version = "VS2017"
  }
}

resource "azurerm_app_service_plan" "dojo_appservice_plan" {
  name                = var.app_service_plan_name
  location            = var.location
  resource_group_name = var.resource_group_name

  sku {
    tier = "Basic"
    size = "B1"
  }
}
terraform {
  required_version = ">= 0.12.28"
  required_providers {
    azurerm = {
      version = "~> 2.12"
    }
  }
}
variable "resource_group_name" {
  description = "The resource group name used for all resources"
  type        = string
}

variable "location" {
  description = "Location"
  type        = string
}

variable "app_service_name" {
  description = "azurerm_app_service_name"
  type        = string
}

variable "app_service_plan_name" {
  description = "azurerm_app_service_plan_name"
  type        = string
}
resource_group_name   = "RG-Dojo-Sandbox"
location              = "Central US"
app_service_name      = "as-dojo-app-service"
app_service_plan_name = "asp-dojo-app-service-plan"