Review Project

Let’s explore the generated app folder.

App Modules

Let’s check out the app/modules/example folder.

resource "azurerm_storage_account" "this" {
  name                      =
  resource_group_name       = var.resource_group_name
  location                  = var.location
  account_tier              = "Standard"
  account_replication_type  = "GRS"
  enable_https_traffic_only = var.enable_https_traffic_only

variable "name" {
  description = "The name of the storage account"
  type        = string

variable "resource_group_name" {
  description = "The name of the resource group"
  type        = string

variable "location" {
  description = "The name of the storage location"
  type        = string

variable "enable_https_traffic_only" {
  description = "forces HTTPS if enabled"
  type        = string
  default     = true

You can see that the starter example module creates an Azure storage account.

Stack Modules

Next let’s look at the generated app/stacks/demo that was created:


resource "random_pet" "this" {
  length = 1 # using 1, since default separator is '-', also account name can only be 24 characters, and lowercase letters

resource "azurerm_resource_group" "this" {
  name     = "demo-resources-${}"
  location = "eastus"

module "storage_account" {
  source                    = "../../modules/example"
  name                      =  "sa${}"
  resource_group_name       =
  location                  = azurerm_resource_group.this.location
  enable_https_traffic_only = var.enable_https_traffic_only

You can see that it’s just another terraform module, that will use the app/modules/example module. It uses the random_pet resource to provide a random but friendly name for the Azure Storage Account. It also creates a Azure Resource Group, which the Storage Account requires.

Modules vs Stacks

Both modules and stacks are terraform modules. The difference is organizational and how they are can be used.

For example, the app1 stack could be designed to use an instance module. Another, app2 stack could use an instance and rds modules.

There are no hard rules. Stacks can be reusable and you provide the tfvars config. It’s up to you. Here are some more Tfvars Location Thoughts.

Next, we’ll deploy the infrastructure.

More tools: