Terraform/OpenTofu is the most widely adopted infrastructure as code tool that allows teams to define and provision infrastructure using a high-level configuration language.
In large organizations, where the complexity and scale of infrastructure can be significant, in addition to using the tool itself, the organisations layer automation, collaboration, and governance features on top using relevant tools/product, as they are crucial for maintaining efficiency and compliance. Let's dissect the phases involved when Infrastructure as code is used in large teams.
Development Phase
The process begins in the development phase, where changes to the infrastructure is proposed.
Here, developers use static analysis tools to ensure code quality and security standards are met before submitting changes for review.
Checkov is a popular Static Analysis tool used in a lot of enterprise set ups
This phase may involve an orchestrator, which is responsible for managing the workflow of tasks, and a plan generator that creates an execution plan for the proposed changes.
Plan Stage
Once the initial code review is passed, the plan stage involves generating a detailed plan of the proposed infrastructure changes.
This includes detecting drift from the current state, scaling considerations, cost estimations, and compliance checks.
The plan preview is essential for understanding the impact of the changes before they are applied.
Tools such as digger can help in plan previews in PR comments
State Management
State management is a critical aspect of Terraform's operation in large organizations.
It involves tracking the state of the infrastructure in a state file.
This allows Terraform to map real-world resources to the configuration, keep track of metadata, and improve performance for large infrastructures.
Risk Assessments
At the center of the workflow is the risk assessment process. This is likely a tool or set of metrics that evaluates the potential risk associated with the changes. This is where the engineering-security team typically steps in.
Factors may include benchmarks and baselines for performance, cost, and security.
The risk assessment is crucial for governance, ensuring that changes adhere to organizational policies and do not introduce unacceptable levels of risk.
Governance and Approvals
Governance in Terraform is enforced through policies that dictate what can be deployed and under what conditions.
Approvals are a part of this governance framework, requiring oversight by senior engineers or automated checks to ensure all standards are met before proceeding.
Version labeling and manifest generation add additional layers of tracking and accountability.
Deployment and Testing
Once the proposed changes have passed through all the previous checks and assessments, they are ready for deployment. The deployment process involves applying the changes to the infrastructure.
This is followed by a series of tests to ensure that the deployment was successful and the infrastructure is operating as expected.
Metrics and Versioning
The final part of the Terraform workflow in large organizations includes metrics collection and versioning.
Metrics and detectors are used to monitor the infrastructure's performance and risk post-deployment, ensuring any anomalies are detected quickly.
Version control is important for tracking changes over time, allowing for audits and rollbacks if necessary.
Digger
Thank you for reading until the end. Before you go, just wanted to share the following:
We're building an Open Source Tool that helps you orchestrate Terraform within CI/CD systems such as GitHub Actions while providing RBAC via OPA, Drift Detection and Concurrency with a self hostable orchestrator backend. Our goal is to essentially provide the set up mentioned above for your team. Would love your feedback!
Top comments (4)
I was using checkov until a few weeks ago, but right now I am receiveing an error in the VSCode extension, because of the token and the page to renew the token is not available anymore. As an alternative I moved to Tfsec, it does not execute a live analisys but it also generates a good report.
Interesting, thanks for sharing!
I didn't know about Checkov, thanks for sharing!
🙌🏻