# Production Readiness Checklist

Ensure your infrastructure is production-ready before deployment.

## Pre-Production Verification

### Infrastructure Requirements

- [ ] All resources properly tagged with environment/owner
- [ ] Security groups/firewall rules configured correctly
- [ ] VPN or bastion host for secure access
- [ ] Backup strategy implemented and tested
- [ ] Disaster recovery plan documented and tested
- [ ] Load balancing configured for HA
- [ ] Database replicas set up
- [ ] Auto-scaling policies configured

### Security Requirements

- [ ] TLS/SSL certificates installed and valid
- [ ] Encryption at rest enabled
- [ ] Encryption in transit (mTLS) enabled
- [ ] Secrets properly stored in vault
- [ ] IAM roles and policies configured
- [ ] Network policies/security groups reviewed
- [ ] SSH keys properly rotated
- [ ] Audit logging enabled

### Operational Requirements

- [ ] Monitoring and alerting configured
- [ ] Log aggregation enabled
- [ ] Health checks configured
- [ ] Runbooks created for common issues
- [ ] On-call procedures established
- [ ] Incident response plan documented
- [ ] SLA defined and tracked

### Testing Requirements

- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Performance tests pass (< SLA threshold)
- [ ] Security tests pass
- [ ] Smoke tests pass
- [ ] Load tests completed
- [ ] Failover testing completed
- [ ] Disaster recovery drill completed

## Configuration Validation

```bash
#!/usr/bin/env nu

def validate-production-config [] {
  print "Validating production configuration..."

  # Check configuration
  provisioning infra validate | | (error "Configuration validation failed")

  # Check security
  provisioning security audit | | (error "Security audit failed")

  # Check capacity
  let resource_utilization = (provisioning capacity check)
  if $resource_utilization.any > 80 {
    print "Warning: Resource utilization > 80%"
  }

  # Verify backups
  let recent_backup = (provisioning backup list --sort date | first)
  let backup_age = ((now) - $recent_backup.date)
  if $backup_age > 86400 {  # > 1 day
    print "Warning: Last backup older than 24 hours"
  }

  print "✓ Configuration validation complete"
}
```

## Performance Baseline

Establish performance metrics before production:

```bash
#!/usr/bin/env nu

def establish-baseline [] {
  print "Establishing performance baseline..."

  # Run load test
  provisioning test load --duration 1h --concurrent-users 1000

  # Capture metrics
  let baseline = {
    response_time_p95 = (provisioning metrics get "response_time_p95"),
    error_rate = (provisioning metrics get "error_rate"),
    throughput_rps = (provisioning metrics get "requests_per_second")
  }

  print $baseline

  # Save for comparison
  $baseline | to json | save baseline-metrics.json
}
```

## Go/No-Go Decision

Final readiness assessment:

```bash
#!/usr/bin/env nu

def production-go-nogo [] {
  let checks = [
    ("Config valid", provisioning infra validate),
    ("Security passed", provisioning security audit),
    ("Tests passed", provisioning test all),
    ("Backups exist", provisioning backup list | length > 0),
    ("Monitoring active", provisioning monitoring status),
    ("Runbooks ready", provisioning runbooks list | length > 5)
  ]

  let all_passed = ($checks | all? { | | c $c.1 == true })

  print "Go/No-Go Decision:"
  $checks | each { | check |
    let status = if $check.1 { "✓" } else { "✗" }
    print $"  ($status) ($check.0)"
  }

  if $all_passed {
    print "✓ GO FOR PRODUCTION"
  } else {
    print "✗ NOT GO - Fix issues above"
  }

  $all_passed
}
```

## Post-Deployment Validation

```bash
#!/usr/bin/env nu

def post-deployment-checks [] {
  print "Running post-deployment validation..."

  sleep 2min  # Allow time for systems to stabilize

  # Run smoke tests
  provisioning test smoke-tests | | (error "Smoke tests failed")

  # Check error rates
  let error_rate = (provisioning metrics get "error_rate")
  if $error_rate > 0.01 {
    error "Error rate above 1%"
  }

  # Verify all services healthy
  let services = (provisioning service status)
  $services | each { | s |
    if $s.status != "running" {
      error $"Service ($s.name) not running"
    }
  }

  print "✓ Post-deployment validation complete"
}
```

## Related Documentation

- [Deployment Strategies](../operations/deployment-strategies.md)
- [Security System](../features/security-system.md)
- [Monitoring](../operations/monitoring.md)
- [Disaster Recovery](./disaster-recovery.md)
