1# ============================================================================= 2# AI Software Factory — Terraform outputs 3# 4# Everything an operator needs after `terraform apply`. The "URL" values are 5# what goes into the app's .env / SSM parameters (see compute.tf header). 6# ============================================================================= 7 8# --- Network ------------------------------------------------------------------- 9 10output "vpc_id" { 11 description = "VPC id." 12 value = aws_vpc.main.id 13} 14 15output "vpc_cidr" { 16 description = "VPC CIDR block." 17 value = aws_vpc.main.cidr_block 18} 19 20output "public_subnet_ids" { 21 description = "Public subnet ids (ALB lives here)." 22 value = aws_subnet.public[*].id 23} 24 25output "private_subnet_ids" { 26 description = "Private subnet ids (app ASGs + RDS + ElastiCache + OpenSearch)." 27 value = aws_subnet.private[*].id 28} 29 30output "availability_zones" { 31 description = "AZs used by the stack." 32 value = local.azs 33} 34 35# --- Security groups -------------------------------------------------------------- 36 37output "security_group_edge_id" { 38 description = "Security group id — edge (ALB)." 39 value = aws_security_group.edge.id 40} 41 42output "security_group_app_id" { 43 description = "Security group id — app (EC2 nodes)." 44 value = aws_security_group.app.id 45} 46 47output "security_group_data_id" { 48 description = "Security group id — data (RDS / ElastiCache / OpenSearch)." 49 value = aws_security_group.data.id 50} 51 52# --- Data services ------------------------------------------------------------------- 53 54output "rds_endpoint" { 55 description = "RDS PostgreSQL endpoint (host:port). Use with POSTGRES_USER=factory and DB_PASSWORD from SSM to build DATABASE_URL." 56 value = aws_db_instance.postgres.endpoint 57 sensitive = true 58} 59 60output "rds_database_name" { 61 description = "RDS database name." 62 value = aws_db_instance.postgres.db_name 63} 64 65output "elasticache_endpoint" { 66 description = "ElastiCache Redis primary endpoint (host:port). Use as REDIS_URL=redis://<endpoint> (no password in this config)." 67 value = aws_elasticache_replication_group.redis.primary_endpoint_address 68} 69 70output "s3_bucket_name" { 71 description = "Uploads S3 bucket (S3_BUCKET in .env)." 72 value = aws_s3_bucket.uploads.id 73} 74 75output "s3_bucket_arn" { 76 description = "Uploads S3 bucket ARN." 77 value = aws_s3_bucket.uploads.arn 78} 79 80# OpenSearch VPC endpoint (https). Use as SEARCH_URL with the admin credentials 81# from SSM (OS_ADMIN_PASSWORD) or a domain user you create after first boot. 82output "opensearch_endpoint" { 83 description = "OpenSearch VPC endpoint URL (SEARCH_URL)." 84 value = "https://${aws_opensearch_domain.main.endpoint}" 85} 86 87# --- Edge / URL ------------------------------------------------------------------- 88 89output "web_alb_dns_name" { 90 description = "Public ALB DNS name (point your A/ALIAS record here)." 91 value = aws_lb.web.dns_name 92} 93 94output "public_url" { 95 description = "Configured public base URL (PUBLIC_BASE_URL / WEB_URL)." 96 value = var.public_url 97} 98 99output "api_url" { 100 description = "Derived API base URL (API_URL)." 101 value = "${var.public_url}/api" 102} 103 104output "realtime_url" { 105 description = "Derived WebSocket URL (REALTIME_URL) — wss:// for https public URLs, ws:// otherwise." 106 value = startswith(var.public_url, "https://") ? replace(var.public_url, "https://", "wss://") : replace(var.public_url, "http://", "ws://") 107} 108 109output "acm_validation_records" { 110 description = "ACM DNS validation records to add to your DNS zone (CNAME records; add manually, then re-apply)." 111 value = { 112 for dvo in aws_acm_certificate.web.domain_validation_options : 113 dvo.domain_name => { 114 name = dvo.resource_record_name 115 type = dvo.resource_record_type 116 value = dvo.resource_record_value 117 } 118 } 119} 120 121# --- SSM parameter reference (for the .env assembly) ------------------------------- 122 123output "ssm_parameter_path" { 124 description = "SSM Parameter Store namespace holding the app env (pre-create parameters here; cloud-init reads them at boot)." 125 value = "/${local.names.project}/${local.env}" 126} 127 128# --- Suggested .env (values to put in SSM / .env.example) -------------------------- 129 130output "suggested_env" { 131 description = "Suggested .env values assembled from this stack (secrets are still in SSM, not here)." 132 value = { 133 DATABASE_URL = "postgresql://factory:<DB_PASSWORD>@${aws_db_instance.postgres.endpoint}?schema=public" 134 REDIS_URL = "redis://${aws_elasticache_replication_group.redis.primary_endpoint_address}" 135 SEARCH_URL = "https://${aws_opensearch_domain.main.endpoint}" 136 S3_BUCKET = aws_s3_bucket.uploads.id 137 S3_REGION = var.aws_region 138 S3_ENDPOINT = "https://${aws_s3_bucket.uploads.bucket_regional_domain_name}" 139 S3_FORCE_PATH_STYLE = "false" 140 PUBLIC_BASE_URL = var.public_url 141 API_URL = "${var.public_url}/api" 142 REALTIME_URL = replace(var.public_url, "https://", "wss://") 143 } 144 sensitive = true 145} 146