Skip to content

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

  1. Install Terraform

  2. Authenticate with GCP

    • Recommended: Use gcloud CLI for credentials
    • Run:
      bash
      gcloud auth application-default login
    • This will configure Application Default Credentials for Terraform.
  3. Select a Workspace

    • We use three Terraform workspaces:
      • dev
      • staging
      • production
    • To select or create a workspace:
      bash
      terraform workspace list
      terraform workspace select <workspace>
      # Or create a new one:
      terraform workspace new <workspace>
  4. Initialize Terraform

    • Navigate to the deploy/ folder:
      bash
      cd deploy
      terraform init
  5. Set Variables

    • Edit variables.tf or use a terraform.tfvars file to set:
      • project_id
      • region
      • environment
  6. Plan and Apply

    • Preview changes:
      bash
      terraform plan
    • Apply changes:
      bash
      terraform apply

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 labels block 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.