Infrastructure as Code (OpenTofu/Terraform)
[TODO] update to tofu and add good practices, add short info about each project
We use OpenTofu (open-source Terraform fork) for Infrastructure-as-Code (IaC) deployment and management.
Status: In Transition
This section is being updated as we transition from Terraform to OpenTofu. The commands and concepts are largely the same.
Installation
Install Terraform
Install Terraform using Homebrew:
Verify Installation
Check the installed version:
Getting Started
Clone the IaC Repository
Clone the infrastructure repository (replace with actual repo URL):
Project Structure
Typical structure:
infrastructure/
├── environments/
│ ├── dev/
│ ├── stage/
│ └── prod/
├── modules/
│ ├── bigquery/
│ ├── storage/
│ └── compute/
├── variables.tf
├── main.tf
└── outputs.tf
Basic Workflow
1. Navigate to Environment
2. Initialize Terraform
Initialize the Terraform project (download providers and modules):
This will: - Download required provider plugins - Initialize the backend - Set up module dependencies
3. Plan Changes
Preview what resources Terraform will create or modify:
Review the output carefully:
- + indicates resources to be created
- ~ indicates resources to be modified
- - indicates resources to be deleted
4. Apply Changes
Apply the configuration to create or update resources:
Terraform will:
1. Show you the plan again
2. Ask for confirmation (type yes)
3. Execute the changes
4. Show you the results