Skip to content

TFE Modules

In this first section, we'll be migrating from using our Azure App service Terraform code that we wrote ourselves and instead, using Cloud Platform's Azure App Service TFE module.

  1. Learn about CEPs module
  2. Refactor Terraform code to utilize TFE modules
  3. Add necessary variables for Terraform code

Modules

Modules are the essential building blocks in writing our Terraform code. They act as templates and serve to provide reusable code with standardized implementation. The Cloud Platform (Cloud Engineering Platform) team owns TFE and is responsible for maintaining modules.

What is a module? A module is a container for multiple resources that are used together (docs). By utilizing these templated modules, they take inputs, create resources, and generate outputs.

Modules are a crucial part in developing our Terraform using standardized templates. There are two main reasons why we will use modules:

  1. We should reuse as much code as possible and Cloud Platform's modules have already been vetted and tested. In order to reduce toil, increasing repeatability and reusability of code is vital, and if we're able to cover most, if not all of our use cases then we should reuse code.
  2. These modules are adhered to security standards and are approved to use.

Locate Cloud Platform's App Service module in TFE

Let's go to TFE's module registry and find CEPs module for App Services.

  • Their module is named app-service-Cloud Platform

What if Cloud Platform doesn't support a module that I need? You can coordinate with Cloud Platform to manage the specification for your modules. You can also follow their innersourcing pattern and SDLC with a pull request. For example, here is their source code for the App Service module.

  • In their docs, you can see multiple versions. For this lab, we will be using version 1.0.24

Module versioning. For this lab, will are pinning to version 1.0.24 of the module. In addition to complying to security standards and recent bug fixes, TFE's Sentinel policies will fail if you use a module version that is deprecated. Cloud Platform publishes new versions frequently, so it is important your keep your code as up-to-date as possible.

Great! We have found Cloud Platform's module and have what we need to update our code and use approved modules in our Terraform.

👷 We will be following their documentation to refactor our Terraform in the next section.