DEV Community

Spacelift team for Spacelift

Posted on

Centralize Infrastructure Governance Without Slowing Developers Down

Centralized infrastructure governance is usually implemented as a review queue, where every change to shared infrastructure routes through a platform team and approval is manual.

However, the number of changes you can review is capped by how many people are reviewing, and the number of changes arriving grows with every team you onboard. Once those two lines cross, waiting for approval becomes the slowest part of shipping infrastructure, and people start going around it. Someone clicks the change into the console to unblock themselves, and it never shows up in a plan again.

The problem is not centralization but what you centralize. Policy, identity, credentials, and audit are all better off with a single owner, but stack ownership, run triggering, and deploy timing are not. Pulling those into the center is what makes governance a bottleneck.

The cost of a rule depends on where you enforce it

Each control’s position in the lifecycle determines what a violation costs to catch.

A rule enforced at ticket intake costs a developer days and a context switch. The same rule in a static IaC scanner runs in seconds, but it only sees the template, not what the template resolves to once modules and variables are evaluated. Evaluated against the plan, it runs in the time it takes to plan, with the real diff available, before anything is applied. Left to a post-deployment audit, it costs a remediation project.

All four cases involve the same rule. The difference is how long it takes to hear about a violation, and how expensive that violation has become by the time you do.

When people call governance slow, they usually mean correct rules sitting in the wrong place. Here are the three patterns that account for most of it:

  • Rules encoded in human review rather than in code, so enforcement throughput scales with headcount
  • Enforcement at intake, where no concrete change exists to inspect, so reviewers approve intentions instead of diffs
  • Binary allow or deny, which routes every edge case to a person

Separate the decision layer from the execution layer

Centralize what has to stay consistent across teams: policy, identity, state, cloud credentials, and audit. Decentralize what generates queues as soon as one team owns it, which is stack ownership, run triggering, and deploy timing.

In Spacelift, Spaces carry that boundary. Spaces are the organizational structure for role-based access control, and every role binds to a specific space.

root/                    policies, shared contexts, cloud integrations
├── platform/            team-scoped admin
└── teams/
    ├── payments/        team-scoped write
    └── search/          team-scoped write
Enter fullscreen mode Exit fullscreen mode

Access propagation is always on, so a binding is inherited by every descendant space. Resource inheritance is a separate per-space toggle, and it runs both ways: It shares a parent’s resources into a child, and it grants the parent Read back on the child. Turning it off isolates a space from root’s shared contexts and cloud integrations, and from the view back up the tree.

Onboarding a team becomes a new space and a role binding rather than a permissions project. If you configured Spacelift several years ago, two mechanisms have changed: Stack-level access policies are removed in favor of Spaces and login policies, and initialization and task policies now fold into approval policies.

Move enforcement to plan time

Plan policies run after the change preview command succeeds, terraform plan or its equivalent for the other supported vendors. The plan body is exported to JSON and merged with Spacelift metadata to form the policy input, so the policy evaluates the actual set of resource changes rather than the source that produced them.

The difference comes down to what each one can see. A static scanner reads your HCL, whereas a plan policy reads input.terraform.resource_changes: every resource address, its type, the actions about to run, and the attribute values after modules, variables, and data sources resolve. Misconfigurations tend to live in exactly that gap, in the values your code computes rather than the ones it declares.

The plan is not omniscient either. Attributes the provider computes at apply time arrive as after_unknown, and sensitive values are hashed before they reach the policy, so rules matching against them need the sanitized() helper. A plan policy sees what your configuration resolves to, not what the cloud will return.

This is also where binary allow-or-deny stops being the only option. A deny rule fails the run outright. A warn rule does not fail the plan, and on an autodeploy stack it holds the apply until a human confirms. Above both, an approval policy decides who has to sign off before a run proceeds and can approve automatically when its conditions are met. Hard rules fail on their own, ambiguous ones are signed off by the relevant person, and routine ones pass through without costing anyone an approval cycle.

Plan is one enforcement point among several:

  • Login policies decide who gets in and with which roles.
  • Push policies decide what a Git push or pull request actually triggers, with the PR’s approval and mergeability state available as input.
  • Approval policies gate the run itself.
  • Trigger policies chain stacks together.

Each one fires at a different moment, which means a rule can sit wherever it costs least to enforce.

The result is a verdict on the pull request in the time it takes to plan, applying the same rule that would otherwise be checked by hand or discovered at audit. One ceiling worth knowing: Spacelift caps total policy evaluation time for all stacks in a single push or pull request event at ten minutes, which matters when one repository backs hundreds of stacks.

Immutable stacks from versioned Templates

Policy evaluates changes after they are written, whereas Templates constrain what can be written in the first place.

A Spacelift Template is a reusable infrastructure configuration your platform team defines once and developers deploy many times with different inputs. Platform engineers work in the Templates Workbench and publish versioned releases pinned to a specific VCS commit. Developers browse a curated list and deploy by filling out a form, with inputs validated before anything runs.

Stacks created from a Template are immutable. They cannot be edited by hand, including by admins, so changes go through the Template itself, either by updating deployment inputs or by publishing a new version.

That constraint is what makes broad deploy access safe. The blast radius of a deployment is limited by the Template before anyone triggers it, so the set of people allowed to deploy does not have to match the set of people you trust to write Terraform.

Version pinning closes the other common objection to self-service. Every published version is pinned to a specific VCS commit, so the same version with the same inputs produces identical infrastructure on every deployment, as long as the Template avoids the usual sources of nondeterminism: unpinned provider constraints, most_recent data source lookups, random_* resources. The commit pin covers your code, not everything your code resolves to at apply time. Publishing a new version leaves existing deployments untouched until you roll them forward.

Enforcement continues after the apply

Everything above runs before the apply. However, infrastructure keeps changing after it, through a console click during an incident, a manual rollback, or a script nobody remembers writing.

Spacelift’s drift detection runs proposed plans against finished state on a schedule you define per stack, and it flags what diverged. It runs on private workers only. If you enable reconciliation, a detected drift triggers a tracked run that passes back through the same plan policies with drift_detection set to true in the input, so you can keep applying ordinary changes automatically while requiring a human to look at anything that drifted. The audit trail records who changed what and when, and dynamic credentials keep cloud access short-lived and scoped to the run that used it.

Note this caveat: Policy-as-code can move the queue rather than remove it. If every policy lives in root and only the platform team can touch it, you have rebuilt the bottleneck one level up with a shorter line. Policies attach per space, so the teams that own a space can own the rules that apply only there, and the center keeps the ones that have to hold everywhere.

Your platform team owns the decisions, your product teams own the execution, and nobody waits in line for something a policy could have answered on its own.

Spacelift’s infrastructure governance page covers how the pieces fit together.

Top comments (0)