# Oracle Cloud Infrastructure 配置
# 管理多个 Oracle Cloud 账户和区域

# 从 Consul 获取 Oracle Cloud 韩国区域配置
data "consul_keys" "oracle_config" {
  key {
    name = "tenancy_ocid"
    path = "config/dev/oracle/kr/tenancy_ocid"
  }
  key {
    name = "user_ocid"
    path = "config/dev/oracle/kr/user_ocid"
  }
  key {
    name = "fingerprint"
    path = "config/dev/oracle/kr/fingerprint"
  }
  key {
    name = "private_key"
    path = "config/dev/oracle/kr/private_key"
  }
}

# 从 Consul 获取 Oracle Cloud 美国区域配置
data "consul_keys" "oracle_config_us" {
  key {
    name = "tenancy_ocid"
    path = "config/dev/oracle/us/tenancy_ocid"
  }
  key {
    name = "user_ocid"
    path = "config/dev/oracle/us/user_ocid"
  }
  key {
    name = "fingerprint"
    path = "config/dev/oracle/us/fingerprint"
  }
  key {
    name = "private_key"
    path = "config/dev/oracle/us/private_key"
  }
}

# 韩国区域的 OCI Provider
provider "oci" {
  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"
}

# 美国区域的 OCI Provider
provider "oci" {
  alias           = "us"
  tenancy_ocid    = data.consul_keys.oracle_config_us.var.tenancy_ocid
  user_ocid       = data.consul_keys.oracle_config_us.var.user_ocid
  fingerprint     = data.consul_keys.oracle_config_us.var.fingerprint
  private_key     = data.consul_keys.oracle_config_us.var.private_key
  region          = "us-ashburn-1"
}
