A CommentOps-based Terraform Pipeline: From Plan to Apply
Building the Infra Provisioning Pipeline
Section titled βBuilding the Infra Provisioning PipelineβAzure Authentication
Section titled βAzure Authenticationβ- Azure CLI login via
az login - The Terraform provisioning environment uses OIDC-based authentication (via an Azure user-assigned managed identity)
export ARM_CLIENT_ID=<clientId>export ARM_SUBSCRIPTION_ID=<subscriptionId>export ARM_TENANT_ID=<tenantId>Basic Setup and Commands
Section titled βBasic Setup and CommandsβCommands run from the directory containing providers.tf. tfvars usage is optional (managed via a digger project on the TACOS tool).
### install the terraform providerterraform init
### validate and generate the planterraform plan
### apply based on the generated planterraform applyGlobal Terraform Settings
Section titled βGlobal Terraform SettingsβIn the local environment, we configure a plugin cache so the Terraform provider runs via symbolic links.
> cat ~/.terraformrcplugin_cache_dir = "~/.terraform.d/plugin-cache/"Directory Structure
Section titled βDirectory StructureβManaged with a module + stacks-based structure.
- digger.yml
Directorymodules
- cache
- container-registry
- cosmosdb
- kubernetes
- network
- sql-database
- sql-server
- vault
- vm-ubuntu
Directorystacks
Directorydev
- backend.tf
- configurations
- data.tf
- main.tf
- outputs.tf
- providers.tf
- variables.tf
Infra Provisioning Flow
Section titled βInfra Provisioning FlowβThe main flow for deploying infra from a Terraform code repository is as follows.

Using TACOS (Terraform Automation & Collaboration Tools)
Section titled βUsing TACOS (Terraform Automation & Collaboration Tools)βTACOS is a collective term for tools that support collaboration and automation for Terraform.
What Is CommentOps?
Section titled βWhat Is CommentOps?β- Pull Requests were originally intended for code review and change-history tracking on development features/hotfixes.
- Integrating a TACOS tool extends this beyond reviewing Terraform code to tracking the history of the actual changes applied.
- Key items managed:
terraform planexecution and its expected resultsterraform applyexecution and what was actually applied- (Optional) Estimated cost simulations for infra changes via other APIs
Comparing the Leading Tools
Section titled βComparing the Leading Toolsβ| Capability/Tool | terraform Cloud | terraform Enterprise | Scalr | Env0 | Spacelift |
|---|---|---|---|---|---|
| Compliance | ISO 27001, SOC 2 | ISO 27001, SOC 2 | β | SOC 2 | ISO 27001, SOC 2 |
| GitLab Integration | β | β | β | β | β |
| Hosting | SaaS | SaaS, On-Prem | SaaS, On-Prem | SaaS | SaaS |
| Policy as Code | Sentinel | Sentinel | OPA | OPA | OPA |
| Pricing Model | Unpredictable in highers tiers | Still figuring it out | Mixed | Mixed | Per capabilities and users |
| Private Agents | β | β | β | β | β |
| Private Module Registry | β | β | β | β | β - with CI/CD |
| RBAC | β | β | βοΈ - hierarchical | βοΈ - hierarchical | βοΈ - also extensible with policies |
| Remote operations CLI | β | β | β | β | β |
| Remote operations VCS/GitOps | β | β | β | β | β |
| SLA | 99.9% for highers tier | N/A | β | β | β |
| SSO | β - only in high paid tiers | β | β - only in high paid tiers | β - only in high paid tiers | β |
| Secrets Management | Internal | Vault integrated | Internal | Internal, AWS, GCP, Azure | Internal, also file based |
| Short lived environments support | β | β | β | β | β |
| State Management | β | β | β | βοΈ - only hidden state | β - also external |
| terraform Provider | β | β | β | β | β |
| Webhooks | β | β | β | β | β |
Atlantis
Section titled βAtlantisβAtlantis integrates tightly with PR workflows on Git solutions like GitHub, and is run self-hosted on a separate K8s environment. It follows the GitHub Flow model.

- Pros
- You can manage Terraform functionality (Plan, Apply) directly from the GitHub comment thread
- Only a single MR is allowed at a time, keeping the infra environment consistently managed
- Cons
- Because only one MR can exist at a time, having multiple contributors creates a bottleneck
- Establishing a variety of branching strategies is relatively difficult
- A separate self-hosted environment is required
Digger is offered as a public service called Digger Cloud, and is mainly used integrated into a GitHub Actions pipeline.
- Pros
- Security: supports RBAC via OIDC and OPA, allowing different permissions per user
- Cost efficiency: reuses your existing CI tooling, requiring no additional compute resources
- Flexibility: supports both apply-on-merge and the traditional approach
- CI/backend separation: the CI tool that performs the Terraform work is separate from the orchestrator that coordinates it, so you keep the benefits of your existing CI tool
- Cons
- Community size: relatively small user base and reference material compared to Atlantis
- Performance: since Atlantis processes the entire workflow on its backend, Digger can be somewhat slower for certain tasks
Key Differences Between Atlantis and Digger
Section titled βKey Differences Between Atlantis and Diggerβ- Execution environment
- Atlantis: runs Terraform on a single VM
- Digger: uses your existing CI infrastructure, spinning up a new Docker container per job
- Security
- Digger: does not directly access cloud accounts or sensitive state data
- Atlantis: executes Terraform directly, so it needs broader access permissions
- Server management
- Digger: in most cases, no self-hosting required
- Atlantis: typically requires maintaining your own server
- Cost
- Digger: cost-efficient by reusing existing CI compute resources
- Atlantis: requires a dedicated, powerful VM instance
- When apply happens
- Digger: supports both pre-merge and post-merge apply
- Atlantis: mainly supports pre-merge apply
- Access control
- Digger: flexible RBAC via OPA policies
- Atlantis: GitHub role-based access control via server options
We ultimately adopted Digger, since it lets us reuse our existing CI infrastructure and removes the burden of maintaining a separate server.
TACOS-based Infra Provisioning in Practice
Section titled βTACOS-based Infra Provisioning in PracticeβWe manage the history of Infra Provisioning Plan/Apply through GitHub Pull-Request-based CommentOps, and integrate the Infracost API to manage cost estimation alongside it.
Digger Integration for Public Access
Section titled βDigger Integration for Public AccessβBuilt around GitHub-hosted runners and APIs that support public access.

Digger Integration for Private Access
Section titled βDigger Integration for Private AccessβBuilt around GitHub self-hosted runners and a self-managed Digger backend service.

Digger Project Configuration
Section titled βDigger Project ConfigurationβThe Digger workflow is configured via digger.yml. Below is an example that adds an Infracost API call step on top of the base plan/apply workflow.
projects:- name: platform-infra-dev dir: stacks/dev workflow: with-infracost
workflows: with-infracost: plan: steps: - init - run: terraform output --raw aks_kube_config > .kubeconfig || true - plan - run: infracost breakdown --path=. | tee -a $DIGGER_OUT apply: steps: - init - run: terraform output --raw aks_kube_config > .kubeconfig || true - apply
auto_merge: falsepr_locks: trueCommentOps in Practice
Section titled βCommentOps in Practiceβ-
Infra deployment plan validation triggered by opening a Pull Request

-
Infra deployment execution via Pull Request review and comments

Infracost Cost Estimation Output
Section titled βInfracost Cost Estimation OutputβBelow is an example output from calling the Infracost API against the Terraform code.
Project: main
Name Monthly Qty Unit Monthly Cost
module.kubernetes_module.azurerm_kubernetes_cluster.aks ββ default_node_pool ββ Instance usage (Linux, pay as you go, Standard_d2as_v5) 730 hours $77.38 ββ os_disk ββ Storage (P10, LRS) 1 months $19.71
module.cache_redis_module.azurerm_redis_cache.cache_redis ββ Cache usage (Basic_C0) 1 nodes $20.44
module.cache_redis_module.azurerm_private_endpoint.pe ββ Private endpoint 730 hour $7.30 ββ Inbound data processed (first 1PB) Monthly cost depends on usage: $0.01 per GB ββ Outbound data processed (first 1PB) Monthly cost depends on usage: $0.01 per GB
module.cosmosdb_mongo_module.azurerm_private_endpoint.pe ββ Private endpoint 730 hour $7.30 ββ Inbound data processed (first 1PB) Monthly cost depends on usage: $0.01 per GB ββ Outbound data processed (first 1PB) Monthly cost depends on usage: $0.01 per GB
module.sqlserver_module.azurerm_private_endpoint.pe ββ Private endpoint 730 hour $7.30 ββ Inbound data processed (first 1PB) Monthly cost depends on usage: $0.01 per GB ββ Outbound data processed (first 1PB) Monthly cost depends on usage: $0.01 per GB
module.vault_module.azurerm_private_endpoint.pe ββ Private endpoint 730 hour $7.30 ββ Inbound data processed (first 1PB) Monthly cost depends on usage: $0.01 per GB ββ Outbound data processed (first 1PB) Monthly cost depends on usage: $0.01 per GB
module.acr_app_module.azurerm_container_registry.acr ββ Registry usage (Basic) 30 days $5.00 ββ Storage (over 10GB) Monthly cost depends on usage: $0.10 per GB ββ Build vCPU Monthly cost depends on usage: $0.0001 per seconds
module.acr_base_module.azurerm_container_registry.acr ββ Registry usage (Basic) 30 days $5.00 ββ Storage (over 10GB) Monthly cost depends on usage: $0.10 per GB ββ Build vCPU Monthly cost depends on usage: $0.0001 per seconds
module.cache_redis_module.azurerm_private_dns_zone.pdz ββ Hosted zone 1 months $0.50
module.cosmosdb_mongo_module.azurerm_private_dns_zone.pdz ββ Hosted zone 1 months $0.50
module.sqlserver_module.azurerm_private_dns_zone.pdz ββ Hosted zone 1 months $0.50
module.vault_module.azurerm_private_dns_zone.pdz ββ Hosted zone 1 months $0.50
module.sqldb_module.azurerm_mssql_database.sqldb ββ Compute (serverless, GP_S_Gen5_2) Monthly cost depends on usage: $0.59 per vCore-hours ββ Storage 2 GB $0.27 ββ Long-term retention (LRS) Monthly cost depends on usage: $0.0295 per GB ββ PITR backup storage (LRS) Monthly cost depends on usage: $0.12 per GB
OVERALL TOTAL $159.00
*Usage costs can be estimated by updating Infracost Cloud settings, see docs for other options.
ββββββββββββββββββββββββββββββββββ27 cloud resources were detected:β 13 were estimatedβ 14 were free
βββββββββββββββββββββββββββββββββββββββββββββββββββββ³ββββββββββββββββ³ββββββββββββββ³ββββββββββββββ Project β Baseline cost β Usage cost* β Total cost ββ£ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ«β main β $159 β - β $159 βββββββββββββββββββββββββββββββββββββββββββββββββββββββ»ββββββββββββββββ»ββββββββββββββ»βββββββββββββTerraform Graph
Section titled βTerraform Graphβ
Next article
Section titled βNext articleβContinue with Azure Resource Deployment Patterns with Terraform.