Eve library

Oshun Infrastructure Environments

Other

Revision 1

On this page

This directory contains environment-specific configurations for deploying Oshun infrastructure to different environments (staging, production).

Structure#

text
environments/
├── staging/           # Staging environment
│   ├── backend.tf     # S3 backend config for staging state
│   ├── main.tf        # Module references and providers
│   ├── outputs.tf     # Environment outputs
│   ├── variables.tf   # Variable definitions
│   └── terraform.tfvars.example  # Example values (copy to terraform.tfvars)
├── production/        # Production environment
│   ├── backend.tf     # S3 backend config for production state
│   ├── main.tf        # Module references and providers
│   ├── outputs.tf     # Environment outputs
│   ├── variables.tf   # Variable definitions
│   └── terraform.tfvars.example  # Example values (copy to terraform.tfvars)
└── README.md          # This file

Usage#

Initial Setup#

  1. Ensure the state backend is deployed first:

    bash
    cd ../state-backend
    terraform init
    terraform apply
    
  2. Copy the example tfvars file:

    bash
    cd environments/staging  # or production
    cp terraform.tfvars.example terraform.tfvars
    # Edit terraform.tfvars with your specific values
    
  3. Initialize the environment:

    bash
    terraform init
    

Planning Changes#

bash
cd environments/staging
terraform plan

Applying Changes#

bash
cd environments/staging
terraform apply

Environment Isolation#

Each environment has:

  • Separate state file in S3 with environment-specific key
  • Separate DynamoDB lock to prevent concurrent modifications
  • Environment-specific variables for sizing, redundancy, and features

Key Differences#

Feature Staging Production
Instance sizes Small (cost-opt) Large (performance)
Multi-AZ Disabled Enabled
Deletion protection Disabled Enabled
Backup retention 7 days 30 days
Monitoring Basic Enhanced
Alerting Slack only PagerDuty + Slack

CI/CD Integration#

The GitHub Actions workflow in .github/workflows/terraform.yml:

  1. Detects changes in infra/terraform/
  2. Runs terraform plan for changed modules
  3. Posts plan output as PR comment
  4. On merge to main:
    • Auto-applies to staging
    • Requires approval for production