# Multi-Cloud Environment Configuration Loader # Reads from config/environments.yaml and creates Terraform data structures locals { # Load environments configuration environments_file = yamldecode(file("${path.module}/../../config/environments.yaml")) # Extract environments list environments = local.environments_file.environments # Filter enabled environments only enabled_environments = { for env in local.environments : env.name => env if env.enabled == true } # Separate by role admin_environments = { for name, env in local.enabled_environments : name => env if env.role == "admin" } workload_environments = { for name, env in local.enabled_environments : name => env if env.role == "workload" } # Group by provider environments_by_provider = { for provider in distinct([for env in local.enabled_environments : env.provider]) : provider => { for name, env in local.enabled_environments : name => env if env.provider == provider } } # Global configuration global_config = local.environments_file.global } # Outputs for debugging and other modules output "environments" { value = local.enabled_environments description = "All enabled environments" sensitive = false } output "admin_environments" { value = local.admin_environments description = "Admin/control plane environments" sensitive = false } output "workload_environments" { value = local.workload_environments description = "Workload environments" sensitive = false } output "environments_by_provider" { value = local.environments_by_provider description = "Environments grouped by cloud provider" sensitive = false } output "global_config" { value = local.global_config description = "Global configuration settings" sensitive = false }