soft guideINFRASTRUCTURE & ADVISORY

Note 08

Three products from one repository with Terramate

One variable selects the package, Terramate composes the stacks, and a renderer gives each client a repository that contains only what they bought.

The problem with feature flags

The platform is sold as three packages. Clients receive the source. Flags that switch off what a client did not buy still ship that code to them: noise to maintain, capabilities they do not have, and the higher packages given away.

One variable composes the stacks

Capabilities live in separate modules per package. A global, tier, decides which modules each stack is generated from; Terramate writes the Terraform and it is committed, so reviewers read real code.

generate_hcl "egress.tf" {
  condition = tm_contains(terramate.stack.tags, "cell") && global.tier != "launch"
  content {
    module "egress" {
      source     = "${terramate.stack.path.to_root}/modules/cell-egress"
      cluster_ip = module.cell.egress.cluster_ip
    }
  }
}

Rendering a client copy

A manifest maps paths to the lowest package that includes them; lines that differ inside shared files carry markers. The renderer copies only what the client's package includes, cuts the marked blocks, sets the tier, regenerates and validates. The result contains no trace of the higher packages.

  egress_allowlist_hosts = [
    "api.stripe.com",
    # >>> tier:autonomous
    "api.anthropic.com",
    # <<< tier:autonomous
  ]

CI renders all three packages from the baseline on every pull request and runs the full checks on each, so a change that leaks a higher package into a lower one fails before it merges.

Start a conversation

Bring your infrastructure
into focus.

Tell me what you are building, operating, or trying to improve.

Let’s talk