← Back to Learn
deploymentbest-practicestutorialreference

Terraform for AI Safety Infrastructure

Authensor

Terraform brings infrastructure-as-code discipline to your AI safety deployment. Version-controlled, peer-reviewed infrastructure changes reduce the risk of misconfigurations that could leave your safety system degraded or offline.

Infrastructure Components

A production Authensor deployment requires: a PostgreSQL database for audit receipts and policy storage, compute resources for the control plane (containers or serverless), a Redis instance for caching (optional but recommended), networking configuration for secure communication, and monitoring infrastructure.

Database Resources

Provision a managed PostgreSQL instance with the following Terraform configuration considerations. Use a production-grade instance class with at least 2 vCPUs and 4 GB of memory. Enable automated backups with a 30-day retention period. Configure encryption at rest. Set up a read replica for Grafana queries and audit trail analysis.

Enable point-in-time recovery. For audit data that may be needed for compliance investigations, the ability to restore to any second within your retention window is essential.

Compute Resources

For container-based deployments, define an ECS service or Kubernetes deployment for the Authensor control plane. Set minimum replicas to 2 for high availability. Configure health check endpoints and autoscaling based on request latency.

For serverless deployments, Authensor's Hono-based control plane runs on AWS Lambda, Cloud Run, or similar platforms. Provision the function with 512 MB of memory and a 30-second timeout.

Networking

Place the database in a private subnet. The control plane needs access to the database and to the internet (for webhook deliveries). Agents need access to the control plane API.

Define security groups that restrict database access to the control plane only. The control plane API should be accessible from your agent VPC or through a public endpoint with API key authentication.

State Management

Store Terraform state in a remote backend (S3 + DynamoDB for locking). Never store state locally for production safety infrastructure. Use separate state files for each environment.

Module Organization

Create reusable modules for common patterns: authensor-database for the PostgreSQL setup, authensor-compute for the control plane deployment, and authensor-monitoring for dashboards and alerts. This lets teams spin up new environments quickly while maintaining consistency.

Tag all resources with environment, project, and cost-center tags. Safety infrastructure costs should be visible and attributable.

Keep learning

Explore more guides on AI agent safety, prompt injection, and building secure systems.

View All Guides