Pull request automation with Atlantis
Atlantis plans and applies Terraform from pull request comments. How atlantis.yaml, requirements and locks work, and the risk of running plan on PR code.
Terraform in CI: saved plans and approvalsOIDC from CI to the cloud
Pull request automation with Atlantis
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Atlantis is a self-hosted app that listens for webhooks, runs plan on pull requests and apply on a comment, and posts the output back to the PR.
- atlantis.yaml maps projects to directories and workspaces; when_modified paths replace the defaults, so list shared modules explicitly.
- apply_requirements such as approved or mergeable gate the apply; some requirement keys are restricted to the server operator.
- Atlantis runs terraform plan on PR code, which can execute malicious code through an external data source or provider, so approvals alone are not enough.
A plan nobody can see
A team is past the laptop stage. The plans run in CI, but they land in a log buried three clicks deep, and the apply happens in a different job. A teammate asks “what is this PR going to do?” and the answer is “run it locally and see.” Reviewers read the HCL diff, which tells them what the author typed, not what Terraform will do.
Atlantis takes a different shape. It is a self-hosted Go application that listens for webhook events from GitHub, GitLab, Bitbucket or Azure DevOps. Its README states the job in one line: it runs terraform plan, import and apply remotely and comments back on the pull request with the output. The conversation about an infrastructure change, the plan, and the apply all happen in the pull request.
The workflow
- You open a pull request that changes Terraform files.
- Atlantis sees the webhook, works out which projects the changed files touch, and runs
planfor each. The plan appears as a comment. - Reviewers read the plan beside the code diff, and comment
atlantis planto re-plan after changes. - Once the PR is approved, someone comments
atlantis apply. - Atlantis applies and posts the output, and the PR is merged.
In the usual Atlantis workflow, as I know it and did not re-read in the docs for this lesson, the apply happens before the merge. That is the opposite of the GitOps default, where merge triggers deployment, and it is a deliberate choice: the plan that was reviewed is the one applied, and if the apply fails, you fix it on the branch before main changes. The cost is that main can briefly lag behind what is applied.
atlantis.yaml
Projects, directories and workspaces are configured in an atlantis.yaml in the repository, and some settings in a server-side file. From the Atlantis docs, this is the shape. I did not run Atlantis and have no server to run it on:
version: 3
projects:
- name: staging-app
dir: envs/staging/app
autoplan:
when_modified: ["*.tf", "../../../modules/**/*.tf", ".terraform.lock.hcl"]
- name: production-app
dir: envs/prod/app
autoplan:
when_modified: ["*.tf", "../../../modules/**/*.tf", ".terraform.lock.hcl"]
apply_requirements: [approved]
The docs say version must be 3, a project is a directory and workspace pair, and when_modified paths are relative to the project directory and replace the defaults entirely. That last point has a trap: if your environment directory calls a module in modules/, the default patterns do not include that module, so a change to the module will not trigger a plan for the environments that use it. The ../../../modules/**/*.tf line above is how you ask for it. This is the same wiring problem Terragrunt and CI path filters solve in other ways.
apply_requirements gates atlantis apply. The docs list the supported requirements as approved, mergeable and undiverged, and say requirement keys like these may be restricted, so the server operator has to allow a repo to set them. The comment commands accept -d for a directory, -w for a workspace and -p for a project name. A bare atlantis apply applies every project, in execution order groups.
Locks
Two pull requests planning the same directory would hit the problem from the CI lesson: the second plan is stale as soon as the first applies. Atlantis addresses it with repository locks. The repo_locks setting has modes disabled, on_plan and on_apply, and the docs describe on_plan as taking a repository lock in the project on plan or apply. I did not find in the docs I read how a lock is released, so I will not state it; check the locking page before you rely on it.
The security question you must answer first
Atlantis runs terraform plan automatically on code from a pull request. A plan evaluates providers and data sources, and the Atlantis security page warns that it is possible to run malicious code in a terraform plan through the external data source or a malicious provider, which could expose the credentials Atlantis holds. Its words for the consequence: terraform apply approvals are not enough when attackers can submit PRs. The mitigations the page lists:
- Keep
--allow-fork-prsdisabled, and avoid public repositories. - Use
--repo-allowlistto limit which repositories can send webhooks. - Set webhook secrets, serve over HTTPS, and enable BasicAuth on the web UI.
- Restrict
--var-file-allowlist, and consider baking providers into the image with restricted egress. - Validate plans with something like Conftest.
- Remember that custom build commands in
atlantis.yamlcome from the PR branch, notmain, so they can run attacker-supplied code.
In other words: Atlantis is a server with production credentials that executes the code of whoever can open a PR. Only let people you already trust with that open PRs, and give the Atlantis role the least privilege you can, using OIDC or instance roles instead of keys.
When Atlantis fits
It suits a team that wants plan-in-PR, wants to host it, and is comfortable operating a service. Atlantis is open source, and as of 28 November 2026 its latest release was v0.50.0, from 21 November. It is not a full platform. In the docs I read it leaves policy checks, drift detection and a rich UI to other tools, so check what you need against its feature list. The alternatives are hand-rolled GitHub Actions, as in the previous lessons, and managed platforms that charge money to run all this for you.
About the video
The embed is env zero’s “Atlantis: Terraform Pull Request Automation Guide”, 10 minutes 56 seconds, October 2023. Its description says Atlantis automates Terraform operations through pull requests, listens for webhooks from GitHub, GitLab, Bitbucket or Azure DevOps, and runs plan and apply from pull request comments. env zero sells a competing product, which does not make the content wrong but is worth knowing. It is from 2023, before Atlantis v0.50, so check flags against the docs. I did not watch it fully, and judged it English from the title, description, channel and its English auto-caption track. Engineering with Morris’s 21-minute walkthrough from March 2025 is in deeper.
Where this fits
Atlantis is the self-hosted end of a spectrum. At the other end is a vendor platform that runs the plan, holds the state and enforces policy: HCP Terraform and managed platforms.
Check yourself
Why does a change to a shared module not trigger a plan with default autoplan paths?
when_modified paths are relative to the project directory and replace the defaults, so the module directory must be listed explicitly.
Why is Atlantis an attractive target?
It holds cloud credentials and runs terraform plan on code from pull requests, which can run attacker-controlled code.
When does the apply happen relative to the merge?
In the usual Atlantis workflow the apply runs from a PR comment before the merge.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.