Skip to content

Several environments in one subscription

One subscription hosts more than one environment, dev and staging in the example, each with its own spoke. Pick it when the customer will not pay for a subscription per environment and the environments share a budget and an owner. Production gets its own subscription; the ALZ policy sets and the blast radius argue against mixing it in.

Example: examples/options/multiple-environments/.

Module docs

Links point at the pinned version. The module examples are applied by the module's own CI on every release.

The tree you add

live/landingzones/corp/corp-shared-nonprod/
├── subscription.hcl
├── env.hcl                     # environment = "dev", the default for _global/
├── _global/
│   ├── region.hcl
│   └── lz-vending/             # places the subscription once
└── westeurope/
    ├── region.hcl
    ├── dev/
    │   ├── env.hcl             # environment = "dev"
    │   └── network/            # vnet-shared-dev-weu, 10.17.0.0/24
    └── staging/
        ├── env.hcl             # environment = "staging"
        └── network/            # vnet-shared-staging-weu, 10.17.1.0/24

root.hcl reads the nearest env.hcl above a unit, so each environment folder overrides the subscription folder's default. The unit code is identical between dev/ and staging/: the names, the env tag and the state key all follow from the folder.

Decisions in the example

  • One placement unit. lz-vending runs once for the subscription. There is no per-environment placement; a management group holds subscriptions, not environments.
  • A spoke per environment. Separate virtual networks keep NSGs, route tables and peerings per environment, and let one environment be torn down without touching the other. Address spaces are adjacent /24s.
  • The subscription's env tag. With several environments in one subscription the subscription-level env tag is wrong for at least one of them. The example leaves subscription tags unmanaged and sets env on every resource group, which the inherit-tag policy respects.
  • Paths in dependencies. The network unit sits one level deeper, so the relative paths to the hub and to lz-vending gain one ../. The example already has them right.

What people get wrong

  • Forgetting the environment env.hcl. The unit then inherits dev from the subscription folder and names every staging resource -dev-. Names cannot be changed later, so check the plan's names before the first apply.
  • Reusing an address space. Two spokes with the same /24 peer to the hub fine and then cannot route to each other.
  • Production in the shared subscription. Policy enforcement, budgets and access reviews are per subscription. Keep prod separate.