Six months ago, our 8-person infrastructure team hit a wall. Engineers were running terraform apply from laptops, which caused silent state drift every week. Our generic CI pipelines were no better—reviewers had to dig through 500-line build logs just to verify a plan before merging. We needed a real GitOps workflow where every change lived inside a Pull Request (or Merge Request on GitLab) with zero guesswork.
So we deployed Atlantis. Six months and roughly 1,400 pull requests later across 12 AWS accounts, it runs quietly on a single 0.5 vCPU container. Here is how Atlantis works in practice, how to spin it up in five minutes, and the sharp edges we hit along the way.
Quick Start: Get Atlantis Running in 5 Minutes
Atlantis is a self-hosted Go binary that listens for webhooks from GitHub, GitLab, or Bitbucket. Open a Pull Request with Terraform changes, and it runs terraform plan automatically. Within seconds, the full plan output lands right in your PR comments.
You do not need a Kubernetes cluster or ECS service to try it out. A local Docker container and a webhook tunnel like ngrok will get the full loop running in five minutes.
1. Prepare Your Credentials
First, create a Personal Access Token (PAT) on GitHub or GitLab with repository read and write permissions, then generate a random webhook secret:
export ATLANTIS_GH_USER="your-bot-username"
export ATLANTIS_GH_TOKEN="ghp_your_personal_access_token"
export ATLANTIS_GH_WEBHOOK_SECRET="$(openssl rand -hex 16)"
export ATLANTIS_REPO_ALLOWLIST="github.com/your-org/infra-repo"
2. Launch Atlantis via Docker
Next, start the official container locally. Production setups belong behind an HTTPS load balancer with persistent storage, but a single Docker command works for testing:
docker run -d --name atlantis \
-p 4141:4141 \
-e ATLANTIS_GH_USER \
-e ATLANTIS_GH_TOKEN \
-e ATLANTIS_GH_WEBHOOK_SECRET \
-e ATLANTIS_REPO_ALLOWLIST \
ghcr.io/runatlantis/atlantis:latest server
Running GitLab instead of GitHub? Swap those variables for ATLANTIS_GITLAB_USER, ATLANTIS_GITLAB_TOKEN, and ATLANTIS_GITLAB_WEBHOOK_SECRET.
3. Add a Minimal atlantis.yaml
Drop an atlantis.yaml file at the root of your Terraform repository so Atlantis knows which directories to track:
version: 3
projects:
- name: networking-dev
dir: envs/dev/networking
terraform_version: v1.9.5
autoplan:
when_modified: ["*.tf", "*.tfvars"]
enabled: true
Point your repository webhook to https://your-atlantis-url/events and open a PR touching a .tf file. Atlantis posts the plan automatically. After a teammate approves, comment atlantis apply to roll out the change.
Deep Dive: How Atlantis Handles GitOps Under the Hood
On the surface, Atlantis looks like a thin wrapper around the Terraform CLI. Six months of daily deploys proved otherwise. Its real value is concurrency control and state safety.
Directory and Workspace Locking
Standard CI pipelines break down when two engineers edit the same Terraform state simultaneously. Pipeline A plans, Pipeline B applies, and then Pipeline A applies a stale plan. That race condition leads straight to accidental deletions.
Atlantis stops this with PR-level locking. Say PR #42 triggers a plan for envs/prod/rds. Atlantis immediately locks that directory-workspace pair. If another engineer opens PR #43 touching envs/prod/rds, Atlantis blocks both planning and applying until PR #42 is merged or unlocked. That single safeguard eliminated at least three state-collision incidents we used to hit every quarter.
Plan Caching and Auto-Merge
Commenting atlantis apply does not trigger a fresh plan and apply it blindly. Instead, Atlantis executes the exact .tfplan file generated during review. Once the apply finishes, it releases the lock—and if you set automerge: true, it merges the Pull Request for you too.
Engineers used to running Terraform locally pick this up fast. The mental model stays the same: plan, review, apply, done. Your Git history simply becomes a clean, searchable audit log of every infrastructure change.
Advanced Usage: Scaling Across Teams and Policy Checks
Default settings work fine for a single repository and a small team. Once multiple squads share production accounts, you need server-side guardrails so nobody can bypass peer review.
Enforcing Server-Side Rules with repos.yaml
Rather than trusting every repository’s atlantis.yaml, pass a central repos.yaml file via --repo-config. Here is the baseline configuration we enforce in production:
repos:
- id: "/.*/"
apply_requirements: [approved, mergeable]
allowed_overrides: [apply_requirements, workflow]
allow_custom_workflows: false
workflow: custom-prod
With apply_requirements: [approved, mergeable], Atlantis blocks atlantis apply until the PR has at least one peer approval and zero merge conflicts. Setting allow_custom_workflows: false also prevents contributors from injecting arbitrary shell commands into repo-level configs.
Adding Policy Checks with Conftest or TFLint
Custom server workflows let you run linting or Open Policy Agent (OPA) checks before a plan even finishes. We wired tflint directly into the plan stage of our repos.yaml:
workflows:
custom-prod:
plan:
steps:
- init
- run: tflint --minimum-failure-severity=error
- plan
Now, a deprecated EC2 instance type or a missing CostCenter tag fails fast. Atlantis posts the exact lint error in the PR thread before a reviewer wastes five minutes reading the plan.
Practical Tips from 6 Months in Production
Operating Atlantis across staging and production taught us five habits that keep deploys predictable as the codebase grows:
- Use short-lived cloud credentials: Never bake static AWS keys into your container. Run Atlantis on EC2, ECS, or EKS with an IAM Role (IRSA) scoped strictly to the environments it manages.
- Pin Terraform versions per project: Atlantis downloads the exact binary listed under
terraform_versioninatlantis.yaml. We keepprodpinned tov1.9.5while testingv1.10safely indev. - Clear stale locks cleanly: Closing a PR normally unlocks its directory automatically, but missed webhooks or abandoned work still happen. Train engineers to comment
atlantis unlock, or clear stuck locks from the web UI on port4141. - Restrict who can approve core applies: Pair GitHub branch protection or GitLab
CODEOWNERSwith Atlantis. Only platform maintainers should be able to approve PRs touching VPC networking or IAM roles. - Persist the data directory: Mount a persistent volume to
/home/atlantis/.atlantis(or your--data-dirpath). Keeping the embedded BoltDB lock database across container restarts prevents active PRs from losing their locks mid-day.
Managing Terraform state locks by hand or scrolling through raw CI logs gets old fast. Six months in, Atlantis remains the lowest-maintenance way we have found to bring real GitOps to Infrastructure as Code.

