Packages

A package combines a resource with the resources that belong to it, behind one input. A storage account package, for example, also creates the account’s containers, queues, file shares, network rules and management policies. Packages are part of the Private edition.

Why use a package

  • One input for a whole service. Describe a storage account and everything inside it in one place, nested the way you think about it, instead of a unit per resource joined by dependency blocks.
  • The IDs are wired for you. A child never asks for its parent’s ID. The package passes the storage account’s ID to each container, and the container’s name to each blob, itself.
  • Created and destroyed in the right order. Where one member refers to another, such as a data factory dataset naming its linked service or a trigger naming its pipeline, the package orders them, so the first apply succeeds and a destroy removes dependants first.
  • Built from the same modules. A package is made of the same generated modules you can use on their own, pinned to the same version, so nothing behaves differently inside one.
  • Mistakes caught early. A package rejects the same configuration set in two places at once (an inline block on the parent and its standalone resource), which the provider would otherwise apply back and forth forever.

An example

terraform {
  source = "git::https://github.com/<your-organisation>/package_azurerm_storage_account.git?ref=v5.8.0"
}

inputs = {
  storage_accounts = {
    0 = {
      name                     = "stappprod"
      resource_group_name      = "rg-app-prod"
      location                 = "uksouth"
      account_tier             = "Standard"
      account_replication_type = "ZRS"

      storage_containers = {
        uploads = { name = "uploads" }
        exports = { name = "exports" }
      }

      storage_queues = {
        jobs = { name = "jobs" }
      }
    }
  }
}

The outputs are the members’ outputs, keyed by the path of keys that leads to each resource: storage_containers_id["0/uploads"] is the ID of the uploads container in account 0. Because / joins the keys, map keys inside a package cannot contain /.

How packages count towards a plan

A package counts as the number of modules in it, up to 5 units. A module you hold inside a package is not counted again on its own. See Pricing for each plan’s allowance.