109 lines
2.8 KiB
HCL
109 lines
2.8 KiB
HCL
# OpenTofu配置 - 使用Terraform的插件缓存
|
|
terraform {
|
|
required_providers {
|
|
oci = {
|
|
source = "oracle/oci"
|
|
version = "7.20.0" # 使用已有的版本
|
|
}
|
|
consul = {
|
|
source = "hashicorp/consul"
|
|
version = "2.22.0" # 使用已有的版本
|
|
}
|
|
}
|
|
}
|
|
|
|
# 从Consul获取韩国区域配置
|
|
data "consul_keys" "oracle_config_kr" {
|
|
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"
|
|
path = "config/dev/oracle/kr/private_key_path"
|
|
}
|
|
key {
|
|
name = "region"
|
|
path = "config/dev/oracle/kr/region"
|
|
}
|
|
}
|
|
|
|
# 从Consul获取美国区域配置
|
|
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"
|
|
path = "config/dev/oracle/us/private_key_path"
|
|
}
|
|
key {
|
|
name = "region"
|
|
path = "config/dev/oracle/us/region"
|
|
}
|
|
}
|
|
|
|
# 韩国区域Provider
|
|
provider "oci" {
|
|
tenancy_ocid = data.consul_keys.oracle_config_kr.var.tenancy_ocid
|
|
user_ocid = data.consul_keys.oracle_config_kr.var.user_ocid
|
|
fingerprint = data.consul_keys.oracle_config_kr.var.fingerprint
|
|
private_key_path = data.consul_keys.oracle_config_kr.var.private_key_path
|
|
region = data.consul_keys.oracle_config_kr.var.region
|
|
}
|
|
|
|
# 美国区域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_path = data.consul_keys.oracle_config_us.var.private_key_path
|
|
region = data.consul_keys.oracle_config_us.var.region
|
|
}
|
|
|
|
# 测试韩国区域连接
|
|
data "oci_identity_compartments" "kr_compartments" {
|
|
compartment_id = data.consul_keys.oracle_config_kr.var.tenancy_ocid
|
|
}
|
|
|
|
# 测试美国区域连接
|
|
data "oci_identity_compartments" "us_compartments" {
|
|
provider = oci.us
|
|
compartment_id = data.consul_keys.oracle_config_us.var.tenancy_ocid
|
|
}
|
|
|
|
# 输出Consul数据
|
|
output "consul_kr_config" {
|
|
value = data.consul_keys.oracle_config_kr.var
|
|
}
|
|
|
|
output "consul_us_config" {
|
|
value = data.consul_keys.oracle_config_us.var
|
|
}
|
|
|
|
# 输出OCI数据
|
|
output "kr_compartments" {
|
|
value = data.oci_identity_compartments.kr_compartments.compartments
|
|
}
|
|
|
|
output "us_compartments" {
|
|
value = data.oci_identity_compartments.us_compartments.compartments
|
|
} |