$ show runatlantis/atlantis
Atlantis is a self-hosted Go application that automates Terraform and OpenTofu workflows triggered by pull request events. It listens for webhooks from GitHub, GitLab, Bitbucket Cloud/Server, Azure DevOps, and Gitea, then executes Terraform commands (plan, apply, import, state rm, version) and reports results via PR comments and commit statuses. The system enforces approval, mergeability, and policy requirements, supports drift detection and remediation, and provides a web UI for lock management and streaming logs. The architecture is a monolithic server with modular components: HTTP controllers for webhook handling, command runners for orchestrating workflows, step runners for individual Terraform operations, VCS client abstractions for multi-provider support, and pluggable persistence (BoltDB embedded, optional Redis, S3 for plan storage). Configuration is layered via server-side YAML, repo-level atlantis.yaml, and CLI flags. Key entry points include main.go (CLI), cmd/server.go (server command), server/controllers/events/events_controller.go (webhook dispatcher), and server/events/command_runner.go (command orchestration). External dependencies include Terraform/OpenTofu binaries, Conftest for policy checks, VCS APIs, and optional Redis/S3. The codebase demonstrates strong engineering practices with extensive unit/integration/e2e tests, instrumentation for metrics, structured logging, and security-conscious design (webhook signature validation, path traversal prevention, shell injection mitigation). While the project is actively maintained, technical drift is medium due to large dependency surface, mock generation sprawl, and complex VCS integration parity.
The LLM identified 5 files worth highlighting for reuse:
Implements a ClientProxy that dispatches VCS operations to the appropriate backend client (GitHub, GitLab, Bitbucket, Azure DevOps, Gitea) based on host type. Demonstrates clean interface segregation and fallback to a no-op client for unconfigured VCS types. Reusable pattern for multi-provider service integrations.
Provides two execution modes: ShellCommandRunner for user-supplied shell commands and NewArgvCommandRunner for Atlantis-built argv vectors. Handles streaming output, large buffer scanning, and environment variable injection. The separation prevents shell injection for internal commands while allowing flexibility for custom workflows. Reusable for any system needing safe command execution.
Utility for splitting long PR comments into multiple parts while respecting markdown code blocks, <details> tags, and inline code. Ensures comments stay under VCS size limits without breaking formatting. Includes truncation headers and continuation markers. Reusable for any system posting formatted messages to VCS or chat platforms.
Defines a consistent API response envelope with success/data/error/request_id/timestamp fields, along with an APIResponder for generating error responses and an APIMiddleware for authentication via constant-time secret comparison. Reusable for building REST APIs with uniform error handling and auth.
Unmarshals workflow steps from multiple YAML/JSON formats: simple strings, maps with extra_args, and command maps for env/run/multienv steps. Demonstrates flexible parsing with validation and fallback. Reusable for any system needing extensible step definitions.