aaa2c06c30
Lifecycle Rules: - Add prevent_destroy = true to all 32+ resources - Add ignore_changes = [tags] to prevent tag drift from causing recreation - Add ignore_changes = [tags, user_data, ami, iam_instance_profile] for EC2 - Preserve existing create_before_destroy for security groups and ACM Import Blocks (orphaned resources): - Lambda: sacc4-stop-instances - Lambda: sacc4-start-instances - EventBridge: sacc4-stop-instances-schedule - EventBridge: sacc4-start-instances-schedule Data Sources: - aws_instances.existing_api (detect EC2 duplicates) - aws_db_instance.existing (detect RDS duplicates) - aws_nat_gateways.existing (detect NAT GW duplicates) - aws_cloudfront_distribution.existing (detect CloudFront duplicates) Variables: - db_identifier: for RDS duplicate detection - cloudfront_distribution_id: for CloudFront duplicate detection Validation Results: - terraform validate: PASSED - terraform plan: 0 to add, 1 to change, 0 to destroy - No resources marked for recreation Orphan EIP detected: - eipalloc-0bdf9c47a80885c7a (78.13.177.201) unattached - Requires manual cleanup or investigation Refs: AWS Resource Validation - May 2026
167 lines
4.8 KiB
Terraform
167 lines
4.8 KiB
Terraform
# ===============================================================================================================
|
|
# variables.tf - Variables de infraestructura para proyectosacc
|
|
# Descripción:
|
|
# Define todas las variables parametrizables de la infraestructura AWS.
|
|
#
|
|
# Autor: Área de Tecnología y Desarrollo - CCsoft
|
|
# ===============================================================================================================
|
|
|
|
# -------------------------------------------------------------------------------
|
|
# Generales
|
|
# -------------------------------------------------------------------------------
|
|
variable "aws_region" {
|
|
description = "Región principal de AWS"
|
|
type = string
|
|
default = "mx-central-1"
|
|
}
|
|
|
|
variable "project_name" {
|
|
description = "Nombre del proyecto"
|
|
type = string
|
|
default = "proyectosacc"
|
|
}
|
|
|
|
variable "environment" {
|
|
description = "Ambiente de despliegue (dev, uat, prod)"
|
|
type = string
|
|
}
|
|
|
|
variable "domain_name" {
|
|
description = "Dominio principal de la aplicación"
|
|
type = string
|
|
default = "sacc.ccsoft.mx"
|
|
}
|
|
|
|
# -------------------------------------------------------------------------------
|
|
# Red
|
|
# -------------------------------------------------------------------------------
|
|
variable "vpc_cidr" {
|
|
description = "CIDR block de la VPC"
|
|
type = string
|
|
default = "10.0.0.0/16"
|
|
}
|
|
|
|
variable "availability_zones" {
|
|
description = "Zonas de disponibilidad a utilizar"
|
|
type = list(string)
|
|
default = ["mx-central-1a", "mx-central-1b"]
|
|
}
|
|
|
|
# -------------------------------------------------------------------------------
|
|
# EC2 (API Backend)
|
|
# -------------------------------------------------------------------------------
|
|
variable "ec2_instance_type" {
|
|
description = "Tipo de instancia EC2 para la API"
|
|
type = string
|
|
default = "t3.small"
|
|
}
|
|
|
|
variable "ec2_ami" {
|
|
description = "AMI de Ubuntu 22.04 LTS"
|
|
type = string
|
|
# AMI oficial de Ubuntu 22.04 LTS en mx-central-1 (validada: 2026-04-10)
|
|
default = "ami-09289f290e76061f8"
|
|
}
|
|
|
|
variable "ec2_root_volume_size" {
|
|
description = "Tamaño del volumen raíz en GB"
|
|
type = number
|
|
default = 20
|
|
}
|
|
|
|
variable "ec2_key_name" {
|
|
description = "Nombre del Key Pair SSH para acceso inicial (administrado externamente)"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "pipeline_public_key" {
|
|
description = "Llave pública SSH del pipeline CI/CD (usuario thoth)"
|
|
type = string
|
|
}
|
|
|
|
variable "allowed_ssh_cidrs" {
|
|
description = "Lista de CIDRs permitidos para acceso SSH (vacío = deshabilitado). Preferir AWS Systems Manager Session Manager en lugar de SSH."
|
|
type = list(string)
|
|
default = []
|
|
}
|
|
|
|
# -------------------------------------------------------------------------------
|
|
# RDS (Base de datos)
|
|
# -------------------------------------------------------------------------------
|
|
variable "db_instance_class" {
|
|
description = "Clase de instancia RDS"
|
|
type = string
|
|
default = "db.t3.micro"
|
|
}
|
|
|
|
variable "db_engine" {
|
|
description = "Motor de base de datos"
|
|
type = string
|
|
default = "mariadb"
|
|
}
|
|
|
|
variable "db_engine_version" {
|
|
description = "Versión del motor de base de datos"
|
|
type = string
|
|
default = "10.11"
|
|
}
|
|
|
|
variable "db_name" {
|
|
description = "Nombre de la base de datos inicial"
|
|
type = string
|
|
default = "sacc_db"
|
|
}
|
|
|
|
variable "db_username" {
|
|
description = "Usuario administrador de la base de datos"
|
|
type = string
|
|
default = "sacc_admin"
|
|
}
|
|
|
|
variable "db_password" {
|
|
description = "Contraseña del usuario administrador de la base de datos"
|
|
type = string
|
|
sensitive = true
|
|
}
|
|
|
|
variable "db_identifier" {
|
|
description = "Identificador de la instancia RDS para verificar existencia (dejar vacío para nueva creación)"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "db_allocated_storage" {
|
|
description = "Almacenamiento asignado a RDS en GB"
|
|
type = number
|
|
default = 20
|
|
}
|
|
|
|
# -------------------------------------------------------------------------------
|
|
# S3
|
|
# -------------------------------------------------------------------------------
|
|
variable "s3_frontend_bucket" {
|
|
description = "Nombre del bucket S3 para el frontend React"
|
|
type = string
|
|
}
|
|
|
|
variable "s3_artifacts_bucket" {
|
|
description = "Nombre del bucket S3 para artefactos de la API"
|
|
type = string
|
|
}
|
|
|
|
# -------------------------------------------------------------------------------
|
|
# CloudFront / ACM
|
|
# -------------------------------------------------------------------------------
|
|
variable "cloudfront_price_class" {
|
|
description = "Clase de precio de CloudFront"
|
|
type = string
|
|
default = "PriceClass_100"
|
|
}
|
|
|
|
variable "cloudfront_distribution_id" {
|
|
description = "ID de la distribución CloudFront existente (dejar vacío para nueva creación)"
|
|
type = string
|
|
default = ""
|
|
}
|