Infrastructure Setup
This document describes the basics of the infrastructure managed by Terraform for the Agri Backend project. All Terraform code is located in the deploy/ folder.
Structure
- deploy/: Root folder for all Terraform code
- vapi/: Vapi service infrastructure (GCS bucket, service account, IAM, etc.)
- variables.tf: Shared variables for project, region, environment, etc.
- main.tf: Main entrypoint for resources
- iam.tf: IAM roles and service account definitions
- outputs.tf: Outputs for integration and reference
Getting Started
Install Terraform
Authenticate with GCP
- Recommended: Use gcloud CLI for credentials
- Run:bash
gcloud auth application-default login - This will configure Application Default Credentials for Terraform.
Select a Workspace
- We use three Terraform workspaces:
devstagingproduction
- To select or create a workspace:bash
terraform workspace list terraform workspace select <workspace> # Or create a new one: terraform workspace new <workspace>
- We use three Terraform workspaces:
Initialize Terraform
- Navigate to the
deploy/folder:bashcd deploy terraform init
- Navigate to the
Set Variables
- Edit
variables.tfor use aterraform.tfvarsfile to set:project_idregionenvironment
- Edit
Plan and Apply
- Preview changes:bash
terraform plan - Apply changes:bash
terraform apply
- Preview changes:
Resources Managed
- Google Cloud Storage buckets for Vapi integrations
- Service accounts for Vapi
- IAM roles and permissions
- HMAC keys for GCS interoperability
Best Practices
- Use labels on all resources for traceability (see
labelsblock in resource definitions) - Store sensitive credentials securely
- Use workspaces for environment separation (dev, staging, prod)
Reference
Update this file as you add new modules or resources to the infrastructure.