170 lines
4.0 KiB
Terraform
170 lines
4.0 KiB
Terraform
|
|
# Phase 2: Variables
|
||
|
|
# File: infrastructure/services/variables.tf
|
||
|
|
|
||
|
|
variable "project_name" {
|
||
|
|
description = "Name of the project"
|
||
|
|
type = string
|
||
|
|
default = "nvhi-atsila-microservice"
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "environment" {
|
||
|
|
description = "Environment name (e.g., dev, staging, prod)"
|
||
|
|
type = string
|
||
|
|
default = "dev"
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "aws_region" {
|
||
|
|
description = "AWS region"
|
||
|
|
type = string
|
||
|
|
default = "us-east-2"
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "common_tags" {
|
||
|
|
description = "Common tags to be applied to all resources"
|
||
|
|
type = map(string)
|
||
|
|
default = {
|
||
|
|
Terraform = "true"
|
||
|
|
Project = "nvhi-atsila-microservice"
|
||
|
|
Environment = "dev"
|
||
|
|
ManagedBy = "jenkins"
|
||
|
|
Pipeline = "services-layer"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# ECS Configuration
|
||
|
|
variable "task_cpu" {
|
||
|
|
description = "CPU units for the ECS task (256, 512, 1024, 2048, 4096)"
|
||
|
|
type = string
|
||
|
|
default = "256" # Free tier friendly
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "task_memory" {
|
||
|
|
description = "Memory for the ECS task (512, 1024, 2048, 4096, 8192)"
|
||
|
|
type = string
|
||
|
|
default = "512" # Free tier friendly
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "desired_count" {
|
||
|
|
description = "Desired number of ECS tasks"
|
||
|
|
type = number
|
||
|
|
default = 1 # Start with 1 for cost efficiency
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "image_tag" {
|
||
|
|
description = "Docker image tag to deploy"
|
||
|
|
type = string
|
||
|
|
default = "latest"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Auto Scaling Configuration
|
||
|
|
variable "enable_auto_scaling" {
|
||
|
|
description = "Enable auto scaling for the ECS service"
|
||
|
|
type = bool
|
||
|
|
default = false # Disable for free tier
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "min_capacity" {
|
||
|
|
description = "Minimum number of tasks"
|
||
|
|
type = number
|
||
|
|
default = 1
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "max_capacity" {
|
||
|
|
description = "Maximum number of tasks"
|
||
|
|
type = number
|
||
|
|
default = 3
|
||
|
|
}
|
||
|
|
|
||
|
|
# Health Check Configuration
|
||
|
|
variable "health_check_path" {
|
||
|
|
description = "Health check path for the application"
|
||
|
|
type = string
|
||
|
|
default = "/health"
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "health_check_interval" {
|
||
|
|
description = "Health check interval in seconds"
|
||
|
|
type = number
|
||
|
|
default = 30
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "health_check_timeout" {
|
||
|
|
description = "Health check timeout in seconds"
|
||
|
|
type = number
|
||
|
|
default = 5
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "health_check_healthy_threshold" {
|
||
|
|
description = "Number of consecutive successful health checks"
|
||
|
|
type = number
|
||
|
|
default = 2
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "health_check_unhealthy_threshold" {
|
||
|
|
description = "Number of consecutive failed health checks"
|
||
|
|
type = number
|
||
|
|
default = 3
|
||
|
|
}
|
||
|
|
|
||
|
|
# Load Balancer Configuration
|
||
|
|
variable "enable_https" {
|
||
|
|
description = "Enable HTTPS listener on ALB"
|
||
|
|
type = bool
|
||
|
|
default = false # Keep simple for demo
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "ssl_certificate_arn" {
|
||
|
|
description = "ARN of SSL certificate for HTTPS"
|
||
|
|
type = string
|
||
|
|
default = null
|
||
|
|
}
|
||
|
|
|
||
|
|
# Blue/Green Deployment Configuration
|
||
|
|
variable "deployment_type" {
|
||
|
|
description = "Deployment type: blue_green or rolling"
|
||
|
|
type = string
|
||
|
|
default = "blue_green"
|
||
|
|
|
||
|
|
validation {
|
||
|
|
condition = contains(["blue_green", "rolling"], var.deployment_type)
|
||
|
|
error_message = "Deployment type must be either 'blue_green' or 'rolling'."
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "deployment_maximum_percent" {
|
||
|
|
description = "Maximum percentage of tasks during deployment"
|
||
|
|
type = number
|
||
|
|
default = 200
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "deployment_minimum_healthy_percent" {
|
||
|
|
description = "Minimum percentage of healthy tasks during deployment"
|
||
|
|
type = number
|
||
|
|
default = 50
|
||
|
|
}
|
||
|
|
|
||
|
|
# CloudWatch Configuration
|
||
|
|
variable "log_retention_days" {
|
||
|
|
description = "CloudWatch log retention in days"
|
||
|
|
type = number
|
||
|
|
default = 7 # Free tier friendly
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "enable_container_insights" {
|
||
|
|
description = "Enable CloudWatch Container Insights"
|
||
|
|
type = bool
|
||
|
|
default = true
|
||
|
|
}
|
||
|
|
|
||
|
|
# Security Configuration
|
||
|
|
variable "enable_execute_command" {
|
||
|
|
description = "Enable ECS Exec for debugging"
|
||
|
|
type = bool
|
||
|
|
default = true
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "enable_service_connect" {
|
||
|
|
description = "Enable ECS Service Connect"
|
||
|
|
type = bool
|
||
|
|
default = false # Keep simple for demo
|
||
|
|
}
|