Teardown and decommissioning¶
Order matters, and getting it wrong leaves resources that cannot be deleted.
Policy before management groups¶
Delete policy assignments, then any custom set-definitions, then custom definitions, then the management groups, bottom-up.
Deleting a management group with a live assignment orphans it
The assignment becomes an un-deletable ghost. If the management group is later recreated, the foundation apply hangs indefinitely trying to recreate that assignment on the inconsistent scope.
Full order¶
- Workload units, leaf first. Destroy each through the repository, in reverse
dependency order: workload resources, then the spoke network, then
lz-vending. Each one follows Decommissioning a unit: delete the unit folder in a pull request, thentfpr apply -p <unit>the destroy plan. - Platform units, the connectivity hub last of those.
- Foundation units:
amba, thenlanding-zones, thenmanagement-resources. This is the reverse of the apply order. - Policy and management groups, as above: assignments, set-definitions, definitions, management groups bottom-up.
- Bootstrap resources, last, and from the bootstrap repository, not the customer repository. The bootstrap owns the runners, the identities, the federated credentials, and the state account.
The state account goes last¶
One storage account holds the state for every unit. Destroy it and every remaining unit loses the record of what it manages, which leaves live Azure resources with no way to destroy them from code. So the state account is removed only after every unit has been destroyed and its state is genuinely empty.
The bootstrap's own state lives in a separate, IP-locked account, which is why the bootstrap can still destroy itself after the customer state account is gone.