Terraform Advanced — Atlantis Setup

less than 1 minute read

Atlantis runs terraform plan and apply via pull request comments.


How Atlantis Works

Developer opens PR → Atlantis auto-runs plan → Posts plan as comment
Developer reviews → Comments "atlantis apply" → Atlantis applies

atlantis.yaml

# atlantis.yaml (repo root)
version: 3
projects:
  - name: networking
    dir: infra/networking
    workspace: default
    autoplan:
      enabled: true
      when_modified:
        - "*.tf"
        - "*.tfvars"

  - name: app
    dir: infra/app
    workspace: default
    autoplan:
      enabled: true
      when_modified:
        - "*.tf"

PR Workflow

$ atlantis plan                    # Plan all projects
$ atlantis plan -p networking      # Plan specific project
$ atlantis apply                   # Apply all planned projects
$ atlantis apply -p networking     # Apply specific project

Server-Side Config

# server-side repo config
repos:
  - id: "github.com/myorg/*"
    allowed_overrides:
      - apply_requirements
    apply_requirements:
      - approved        # PR must be approved
      - mergeable       # No merge conflicts

💡 Production Tip: Require PR approval before atlantis apply. This ensures at least one person reviews the plan before infrastructure changes.


What’s Next?

Use Terraform Cloud for managed runs.

← GitLab CI Terraform Cloud Runs →

Updated: