Security & FinOps · Plan-time guards

Typos Cannot Reach Production: Declarative SaaS Access with Plan-Time Guards

A Terraform stack maps users, teams, projects and access levels to a managed-database platform, protected by lifecycle preconditions.

  • Terraform
  • MongoDB Atlas provider
  • Terraform locals

// Overview

Users have org roles and team memberships; teams get per-project access levels, and group-style role bundles let a user inherit org roles. A guard resource aborts the plan if an email is in a disallowed domain, a role is not allow-listed, a team or user is unknown or an access level is undefined. Every real resource depends on the guard.

// The problem

Third-party SaaS access is usually granted in a UI, where typos and external addresses are easy to introduce.

// Flow

Typos Cannot Reach Production: Declarative SaaS Access with Plan-Time Guards flow1. Edit access map → 2. Guard evaluation → 3. Abort or continue → 4. Teams created → 5. Project access → 6. Apply01Edit access map02 · GATEGuard evaluation03Abort or continue04Teams created05Project access06Apply
  1. Edit access mapusers, teams, projects, levels in config
  2. Guard evaluation gatepreconditions on domain, role allow-list and references
  3. Abort or continuefailure stops the plan before any API call
  4. Teams createdthen invitations and team assignments
  5. Project accessteam and user grants resolved from levels
  6. Applythrough the normal pipeline

// Design decisions & guardrails

  • Preconditions rather than check blocks, so failure blocks the plan.
  • Effective roles are own plus group-derived, de-duplicated.
  • Invitations require acceptance before access takes effect.

// Outcome

Invalid access can no longer be planned, let alone applied.

// Related