Skip to content

feat(terraform): add multi-cloud infrastructure with OCI free tier support#127

Merged
ericfitz merged 11 commits intomainfrom
feature/terraform-multi-cloud
Jan 31, 2026
Merged

feat(terraform): add multi-cloud infrastructure with OCI free tier support#127
ericfitz merged 11 commits intomainfrom
feature/terraform-multi-cloud

Conversation

@ericfitz
Copy link
Owner

Summary

  • Add Terraform modules for deploying TMI to Oracle Cloud Infrastructure (OCI) free tier
  • Implement OCI cloud logging with Resource Principal authentication for Container Instances
  • Fix Oracle ADB connectivity, wallet handling, and Redis authentication for OCI deployment
  • Add modular infrastructure: network, database, secrets, logging, and compute modules

Key Features

Terraform Infrastructure

  • Network module: VCN, subnets, security lists, NAT/Internet gateways
  • Database module: Oracle Autonomous Database (ADB) with wallet management
  • Secrets module: OCI Vault integration for secure credential storage
  • Logging module: OCI Logging service with dynamic groups and IAM policies
  • Compute module: Container Instances with load balancer and health checks

Cloud Logging

  • New internal/slogging cloud logging framework with pluggable writers
  • OCI cloud writer using Resource Principal auth (correct for Container Instances)
  • Automatic fallback: Resource Principal → Instance Principal → Default config
  • Configurable via environment variables (TMI_CLOUD_LOG_ENABLED, TMI_OCI_LOG_ID)

OCI Deployment Fixes

  • Fixed dynamic group resource type (computecontainerinstance not containerinstance)
  • Fixed Oracle wallet extraction and sqlnet.ora path configuration
  • Fixed Redis AUTH command handling for OCI deployment
  • Fixed SystemSetting migration for Oracle ADB compatibility

Files Changed

  • 36 files changed, ~3,900 lines added
  • New terraform modules in terraform/modules/{network,database,secrets,logging,compute}/oci/
  • New environment in terraform/environments/oci-free-tier/
  • Cloud logging in internal/slogging/{cloud_writer,oci_cloud_writer}.go

Test plan

  • Terraform plan validates without errors
  • Container builds successfully with Dockerfile.server-oracle
  • Container Instance deploys and runs healthy in OCI
  • Logs appear in OCI Logging service (166 entries confirmed)
  • API responds with HTTP 200 at load balancer endpoint
  • Full integration test with threat model CRUD operations

🤖 Generated with Claude Code

ericfitz and others added 8 commits January 29, 2026 09:21
…yment

Add Terraform modules for deploying TMI to Oracle Cloud Infrastructure:

- Network module: VCN, subnets, gateways, NSGs
- Database module: Autonomous Database Free Tier with private endpoint
- Secrets module: OCI Vault with secrets and IAM policies
- Logging module: Log groups, service connectors, alarms
- Compute module: Container instances and load balancer

Environment configuration for OCI Free Tier included with sensible defaults.

Makefile targets added:
- tf-init, tf-plan, tf-apply, tf-destroy
- deploy-oci, deploy-oci-plan

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add CloudLogWriter interface and OCI Logging implementation:

- CloudLogWriter: Generic interface for cloud logging providers
- CloudLogHandler: slog.Handler that writes to both local and cloud
- OCICloudWriter: OCI Logging service implementation
  - Batched async writes with configurable buffer
  - Automatic flush on timeout or buffer full
  - Health tracking and graceful degradation
- NoopCloudWriter: For testing or when cloud logging disabled

Cloud logging is additive - local file/console logging continues
to work independently. If cloud logging fails, only cloud writes
are affected; local logging remains uninterrupted.

Configuration options:
- CloudWriter: Provider instance (nil to disable)
- CloudLogLevel: Minimum level for cloud (defaults to local level)
- CloudLogBufferSize: Async buffer size (default: 1000)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add TMI_DATABASE_URL environment variable for Oracle ADB connection
- Fix OCI provider v7.x API changes (ip_addresses format)
- Update database module for ECPU model (remove cpu_core_count)
- Make private endpoint conditional for free tier (not supported)
- Disable bucket versioning for log archive (conflicts with retention)
- Add sensitive flag to outputs containing credentials
- Comment out container logging (incorrect service name)
- Add region variable to database module for wallet PAR URL

These changes enable successful deployment of TMI on OCI Always Free tier
resources including Oracle Autonomous Database, Container Instances,
Load Balancer, and OCI Vault for secrets management.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add bash and unzip packages to Oracle container image
- Fix slogging to respect TMI_LOG_DIR during early initialization
- Add JWT secret variable and env config to compute module
- Add HTTPS egress rule for ADB Free Tier public endpoint
- Increase health check initial delay to 60s
- Improve entrypoint script with detailed debugging output
- Remove Docker HEALTHCHECK (conflicts with OCI health check)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix entrypoint script sed pattern to properly update sqlnet.ora
  DIRECTORY path using non-greedy regex [^"]* instead of .*
- Change REDIS_URL to TMI_REDIS_URL to match app config expectations
- Remove Redis password from URL since distroless Redis container
  doesn't support password auth (TODO for future fix)

The container now successfully connects to Oracle ADB using wallet
authentication and to Redis for caching/session management.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove GORM default tag from SystemSetting.SettingType that caused
  Oracle migration to fail silently (unquoted 'string' parsed as identifier)
- Add Redis password to TMI_REDIS_URL in terraform config for proper
  authentication with Oracle Linux Redis container
- Add --platform linux/amd64 flag to container build script for OCI
  Container Instances which use AMD64 shapes

These fixes resolve ORA-00942 (table not found) errors during server
startup and NOAUTH authentication errors when connecting to Redis.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add cloud logging initialization from environment variables in main.go
- Support Resource Principal authentication for OCI Container Instances
- Wire OCI Logging service to compute module via oci_log_id variable
- Add cloud_log_level configuration for filtering cloud logs
- Fix dynamic group matching rule to use 'computecontainerinstance' resource type

Cloud logging is now automatically enabled when TMI_CLOUD_LOG_ENABLED=true
with TMI_OCI_LOG_ID set. Uses Resource Principal for Container Instances,
falls back to Instance Principal for VMs, then to ~/.oci/config for local dev.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These are fixes to the terraform-multi-cloud feature, not a new feature.
Skipping post-commit hook to prevent auto-increment.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dosubot dosubot bot added the enhancement New feature or request label Jan 31, 2026
CodeQL alert #1221 - unsafe quoting vulnerability in OCI cloud writer.
Use json.Marshal to properly escape special characters in the message
before embedding in the JSON fallback string.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Avoid string interpolation entirely by marshaling a map struct.
CodeQL go/unsafe-quoting doesn't trust fmt.Sprintf even with
pre-marshaled values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ericfitz ericfitz merged commit 24f7dad into main Jan 31, 2026
7 checks passed
@ericfitz ericfitz deleted the feature/terraform-multi-cloud branch January 31, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant