From 43591cec93d4e0951a9a335243b72291aca45cdb Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Sun, 24 Aug 2025 12:03:12 +0700 Subject: [PATCH] fix(infra): only include provider matching cloud --- infra/production/root.hcl | 41 +++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/infra/production/root.hcl b/infra/production/root.hcl index bf9f9db..6513a17 100644 --- a/infra/production/root.hcl +++ b/infra/production/root.hcl @@ -1,6 +1,7 @@ locals { secrets = yamldecode(sops_decrypt_file(find_in_parent_folders("secrets.yaml"))) env = "production" + cloud = split("/", path_relative_to_include())[0] } generate "backend" { @@ -35,19 +36,35 @@ generate "provider" { path = "provider.tf.json" if_exists = "overwrite" disable_signature = true - contents = jsonencode({ - provider = { - oci = { - tenancy_ocid = local.secrets.oracle_tenancy_ocid - user_ocid = local.secrets.oracle_user_ocid - fingerprint = local.secrets.oracle_fingerprint - private_key = local.secrets.oracle_private_key - region = local.secrets.oracle_region + + contents = jsonencode(lookup( + { + oracle = { + provider = { + oci = { + tenancy_ocid = local.secrets.oracle_tenancy_ocid + user_ocid = local.secrets.oracle_user_ocid + fingerprint = local.secrets.oracle_fingerprint + private_key = local.secrets.oracle_private_key + region = local.secrets.oracle_region + } + } + } + hetzner = { + provider = { + hcloud = {} + } } proxmox = { - endpoint = "https://proxmox:8006" - insecure = true + provider = { + proxmox = { + endpoint = "https://proxmox:8006" + insecure = true + } + } } - } - }) + }, + local.cloud, + {} + )) } -- 2.51.2