# ===== DEPRECATED: Amplify Outputs (removed after migration to CloudFront) =====
# output "app_id" {
#   description = "The ID of the Amplify app"
#   value       = aws_amplify_app.filamenteka.id
# }
#
# output "app_url" {
#   description = "The default URL of the Amplify app"
#   value       = "https://main.${aws_amplify_app.filamenteka.default_domain}"
# }
#
# output "dev_url" {
#   description = "The development branch URL"
#   value       = "https://dev.${aws_amplify_app.filamenteka.default_domain}"
# }
#
# output "custom_domain_url" {
#   description = "The custom domain URL (if configured)"
#   value       = var.domain_name != "" ? "https://${var.domain_name}" : "Not configured"
# }

output "rds_endpoint" {
  value       = aws_db_instance.filamenteka.endpoint
  description = "RDS instance endpoint"
}

output "rds_database_name" {
  value       = aws_db_instance.filamenteka.db_name
  description = "Database name"
}

output "rds_username" {
  value       = aws_db_instance.filamenteka.username
  description = "Database username"
}

output "rds_password_secret_arn" {
  value       = aws_secretsmanager_secret.db_credentials.arn
  description = "ARN of the secret containing the database password"
}

output "database_url" {
  value       = "postgresql://${aws_db_instance.filamenteka.username}:[PASSWORD]@${aws_db_instance.filamenteka.endpoint}/${aws_db_instance.filamenteka.db_name}"
  description = "Database connection URL (replace [PASSWORD] with actual password from Secrets Manager)"
  sensitive   = true
}

output "ecr_repository_url" {
  value       = aws_ecr_repository.api.repository_url
  description = "ECR repository URL for API Docker images"
}

output "api_instance_id" {
  value       = aws_instance.api.id
  description = "API EC2 instance ID"
}

output "aws_region" {
  value       = var.aws_region
  description = "AWS Region"
}

# CloudFront + S3 Frontend Outputs
output "s3_bucket_name" {
  value       = aws_s3_bucket.frontend.id
  description = "S3 bucket name for frontend"
}

output "cloudfront_distribution_id" {
  value       = aws_cloudfront_distribution.frontend.id
  description = "CloudFront distribution ID"
}

output "cloudfront_domain_name" {
  value       = aws_cloudfront_distribution.frontend.domain_name
  description = "CloudFront distribution domain name"
}

output "frontend_url" {
  value       = var.domain_name != "" ? "https://${var.domain_name}" : "https://${aws_cloudfront_distribution.frontend.domain_name}"
  description = "Frontend URL"
}

