# Phase 2: Outputs # File: infrastructure/services/outputs.tf # Application Load Balancer Information output "alb_arn" { description = "ARN of the Application Load Balancer" value = aws_lb.main.arn } output "alb_dns_name" { description = "DNS name of the Application Load Balancer" value = aws_lb.main.dns_name } output "alb_zone_id" { description = "Zone ID of the Application Load Balancer" value = aws_lb.main.zone_id } output "application_url" { description = "URL to access the application" value = "http://${aws_lb.main.dns_name}" } output "health_check_url" { description = "URL for health check endpoint" value = "http://${aws_lb.main.dns_name}/health" } # ECS Information output "ecs_cluster_name" { description = "Name of the ECS cluster" value = aws_ecs_cluster.main.name } output "ecs_cluster_arn" { description = "ARN of the ECS cluster" value = aws_ecs_cluster.main.arn } output "ecs_service_name" { description = "Name of the ECS service" value = aws_ecs_service.app.name } output "ecs_service_arn" { description = "ARN of the ECS service" value = aws_ecs_service.app.id } output "ecs_task_definition_arn" { description = "ARN of the ECS task definition" value = aws_ecs_task_definition.app.arn } output "ecs_task_definition_family" { description = "Family of the ECS task definition" value = aws_ecs_task_definition.app.family } output "ecs_task_definition_revision" { description = "Revision of the ECS task definition" value = aws_ecs_task_definition.app.revision } # ECR Information output "ecr_repository_url" { description = "URL of the ECR repository" value = aws_ecr_repository.app.repository_url } output "ecr_repository_name" { description = "Name of the ECR repository" value = aws_ecr_repository.app.name } output "ecr_repository_arn" { description = "ARN of the ECR repository" value = aws_ecr_repository.app.arn } # Target Groups for Blue/Green Deployment output "blue_target_group_arn" { description = "ARN of the Blue target group" value = aws_lb_target_group.blue.arn } output "green_target_group_arn" { description = "ARN of the Green target group" value = aws_lb_target_group.green.arn } output "blue_target_group_name" { description = "Name of the Blue target group" value = aws_lb_target_group.blue.name } output "green_target_group_name" { description = "Name of the Green target group" value = aws_lb_target_group.green.name } # IAM Role Information output "ecs_task_execution_role_arn" { description = "ARN of the ECS task execution role" value = aws_iam_role.ecs_task_execution.arn } output "ecs_task_role_arn" { description = "ARN of the ECS task role" value = aws_iam_role.ecs_task.arn } # CloudWatch Information output "cloudwatch_log_group_name" { description = "Name of the CloudWatch log group" value = aws_cloudwatch_log_group.app.name } output "cloudwatch_log_group_arn" { description = "ARN of the CloudWatch log group" value = aws_cloudwatch_log_group.app.arn } # Monitoring Information output "cpu_alarm_name" { description = "Name of the CPU utilization alarm" value = aws_cloudwatch_metric_alarm.high_cpu.alarm_name } output "memory_alarm_name" { description = "Name of the memory utilization alarm" value = aws_cloudwatch_metric_alarm.high_memory.alarm_name } # Docker Build Information (for CI/CD) output "docker_build_commands" { description = "Commands to build and push Docker image" value = { login = "aws ecr get-login-password --region ${var.aws_region} | docker login --username AWS --password-stdin ${aws_ecr_repository.app.repository_url}" build = "docker build -t ${aws_ecr_repository.app.name} ." tag = "docker tag ${aws_ecr_repository.app.name}:latest ${aws_ecr_repository.app.repository_url}:latest" push = "docker push ${aws_ecr_repository.app.repository_url}:latest" } } # ECS Deployment Commands (for CI/CD) output "ecs_deployment_commands" { description = "Commands for ECS deployment" value = { update_service = "aws ecs update-service --cluster ${aws_ecs_cluster.main.name} --service ${aws_ecs_service.app.name} --force-new-deployment" wait_stable = "aws ecs wait services-stable --cluster ${aws_ecs_cluster.main.name} --services ${aws_ecs_service.app.name}" describe = "aws ecs describe-services --cluster ${aws_ecs_cluster.main.name} --services ${aws_ecs_service.app.name}" } } # Blue/Green Deployment Commands output "blue_green_commands" { description = "Commands for Blue/Green deployment" value = { switch_to_green = "aws elbv2 modify-listener --listener-arn ${aws_lb_listener.main.arn} --default-actions Type=forward,TargetGroupArn=${aws_lb_target_group.green.arn}" switch_to_blue = "aws elbv2 modify-listener --listener-arn ${aws_lb_listener.main.arn} --default-actions Type=forward,TargetGroupArn=${aws_lb_target_group.blue.arn}" check_health_green = "aws elbv2 describe-target-health --target-group-arn ${aws_lb_target_group.green.arn}" check_health_blue = "aws elbv2 describe-target-health --target-group-arn ${aws_lb_target_group.blue.arn}" } } # Project Information output "project_name" { description = "Name of the project" value = var.project_name } output "environment" { description = "Environment name" value = var.environment } output "aws_region" { description = "AWS region" value = var.aws_region } # Cost Optimization Information output "cost_estimate" { description = "Estimated monthly cost breakdown" value = { ecs_fargate = "$0-15/month (depends on usage)" alb = "$18/month (fixed cost)" ecr = "$0-1/month (500MB free)" cloudwatch = "$0-3/month (free tier)" total_estimate = "$18-37/month" note = "Actual costs depend on traffic and usage patterns" } }