# 开发环境主配置文件

# 引入共享版本配置
terraform {
  required_version = ">= 1.6"
  
  required_providers {
    # Oracle Cloud Infrastructure
    oci = {
      source  = "oracle/oci"
      version = "~> 7.20"
    }
    
    # 其他常用提供商
    random = {
      source  = "hashicorp/random"
      version = "~> 3.1"
    }
    
    tls = {
      source  = "hashicorp/tls"
      version = "~> 4.0"
    }
    
    local = {
      source  = "hashicorp/local"
      version = "~> 2.1"
    }
    
    # Consul Provider
    consul = {
      source  = "hashicorp/consul"
      version = "~> 2.22.0"
    }
    
    # HashiCorp Vault Provider
    vault = {
      source  = "hashicorp/vault"
      version = "~> 4.0"
    }
    
    # DigitalOcean Provider
    digitalocean = {
      source  = "digitalocean/digitalocean"
      version = "~> 2.0"
    }
    
    # Cloudflare Provider
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "~> 4.0"
    }
  }
  
  # 后端配置
  backend "local" {
    path = "terraform.tfstate"
  }
}

# Consul Provider配置
provider "consul" {
  address    = "localhost:8500"
  scheme     = "http"
  datacenter = "dc1"
}

# Vault Provider配置
provider "vault" {
  address = var.vault_config.address
  token   = var.vault_token
}

# Oracle Cloud 配置已移至 oracle.tf

# Oracle Cloud 基础设施 - 暂时注释掉以避免VCN数量限制问题
# module "oracle_cloud" {
#   source = "../../providers/oracle-cloud"
#   
#   # 传递变量
#   environment    = var.environment
#   project_name   = var.project_name
#   owner          = var.owner
#   vpc_cidr       = var.vpc_cidr
#   availability_zones = var.availability_zones
#   common_tags    = var.common_tags
#   
#   # 使用从Consul获取的配置
#   oci_config = {
#     tenancy_ocid     = data.consul_keys.oracle_config.var.tenancy_ocid
#     user_ocid        = data.consul_keys.oracle_config.var.user_ocid
#     fingerprint      = data.consul_keys.oracle_config.var.fingerprint
#     private_key      = data.consul_keys.oracle_config.var.private_key
#     region           = "ap-chuncheon-1"
#     compartment_ocid = data.consul_keys.oracle_config.var.tenancy_ocid  # 使用tenancy_ocid作为compartment_ocid
#   }
#   
#   # 开发环境特定配置
#   instance_count = 1
#   instance_size  = "VM.Standard.E2.1.Micro"  # 免费层
#   
#   providers = {
#     oci = oci
#   }
# }

# 输出
# output "oracle_cloud_outputs" {
#   description = "Oracle Cloud 基础设施输出"
#   value       = module.oracle_cloud
# }