Skip to content

Dev & Model Environments

Next, you will need to update our variable definitions in workshop.auto.tfvars to work with the new Cloud Platform modules you migrated to in the prior section. In the Cloud Platform TFE modules, variables are given values in a slightly different manner, instead of files like workshop.auto.tfvars we will use dev.tfvars, model.tfvars and prod.tfvars.

In the next section, you will learn about the pipeline templates and how they will assist you with using these Cloud Platform modules in a pipeline. A part of what the pipeline templates handle is the input of variables into TFE. They read dev.tfvars, model.tfvars and prod.tfvars. Depending on which environment the pipeline is deploying to, it takes these files and sets up an auto.tfvars file and passes that along to TFE. In this way, all of the app vars per environment can be managed in a file corresponding to the environment.

Dev Environment Variables

Go ahead and rename workshop.auto.tfvars to dev.tfvars. This will serve to define the values for all of our variables in the dev environment. In the future, you will create your own prod.tfvars with the info for that environment, when you are ready to make deployments into the production environment.

Example dev.tfvars before changes (this is just workshop.auto.tfvars renamed)
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"

You now can make changes to our dev.tfvars file to match up with the changes you made in the variables.tf file in the last section. By making these changes you will be able to properly interface with the modules provided by Cloud Platform. First, remove location, and update the App Service size and tier values. Below is an example of a well-defined dev.tfvars file.

dev.tfvars
resource_group_name   = "RG-Dojo-Sandbox"
app_service_plan_name = "ase-plan-dojo-workshop-dev"
asp_service_size      = "S1"
app_service_tier      = "Standard"
appservices = {
  ase-dojo-workshop-dev = {
    connectionstrings = []
    appsettings       = {}
    sitesettings = {
      dotnet_framework_version    = "v4.0"
      min_tls_version             = "1.2"
      always_on                   = true
      ftps_state                  = "Disabled"
      http2_enabled               = false
      managed_pipeline_mode       = "Integrated"
      remote_debugging_enabled    = false
      remote_debugging_version    = "VS2019"
      scm_type                    = "VSTSRM"
      scm_use_main_ip_restriction = false
      websockets_enabled          = false
      default_documents           = ["index.html"]
    }
    generalsettings = {
      client_affinity_enabled = false
    }
    managed_identity = {
      type = "SystemAssigned"
      id   = [""]
    }
  }
}

Model Environment Variables

Next, you will create a model.tfvars file, and fill it in with info similar to your dev.tfvars file, however you will make just a few slight changes to get your variables working in the model environment. There are only minor differences here, so make sure you analyze the code and familiarize yourself with the differences in your dev and model environment deployments.

model.tfvars
resource_group_name   = "RG-Dojo-Sandbox"
app_service_plan_name = "ase-plan-dojo-workshop-model"
asp_service_size      = "S1"
app_service_tier      = "Standard"
appservices = {
  ase-dojo-workshop-model = {
    connectionstrings = []
    appsettings       = {}
    sitesettings = {
      dotnet_framework_version    = "v4.0"
      min_tls_version             = "1.2"
      always_on                   = true
      ftps_state                  = "Disabled"
      http2_enabled               = false
      managed_pipeline_mode       = "Integrated"
      remote_debugging_enabled    = false
      remote_debugging_version    = "VS2019"
      scm_type                    = "VSTSRM"
      scm_use_main_ip_restriction = false
      websockets_enabled          = false
      default_documents           = ["index.html"]
    }
    generalsettings = {
      client_affinity_enabled = false
    }
    managed_identity = {
      type = "SystemAssigned"
      id   = [""]
    }
  }
}

At this point, the modules we built in the Terraform Primer have been completely converted to use the enterprise standard methodology of utilizing modules and tfvars files.

In the next section, we will write out a pipeline that will be capable of deploying our infrastructure to multiple environments.