code: def terraform_write_variables(
      configs: Dict, variables_to_exclude: List
  ) -> str:
      """Write out given config object as a Terraform variables JSON file.
  
      Persist variables to Terraform state directory.  These variables are used
      on apply / plan, and are required for deprovisioning.
      """
      det_version = configs.get("det_version")
      if not det_version or not isinstance(det_version, str):
          print("ERROR: Determined version missing or invalid")
          sys.exit(1)
  
      # Add GCP-friendly version key to configs. We persist this since it's used
      # across the cluster lifecycle: to name resources on provisioning, and to
      # filter for the master and dynamic agents on deprovisioning.
      configs["det_version_key"] = det_version.replace(".", "-")[
          :12
      ].rstrip("-")
  
      # Track the default zone in configuration variables. This is needed
      # during deprovisioning.
      if "zone" not in configs:
          configs["zone"] = f"{configs['region']}-b"
  
      vars_file_path = get_terraform_vars_file_path(configs)
  
      tf_vars = {
          k: configs[k]
          for k in configs
          if k not in variables_to_exclude
      }
      with open(vars_file_path, "w") as f:
          json.dump(tf_vars, f)
  
      return vars_file_path
  
imports: import json
  import os
  import shutil
  import subprocess
  import sys
  import time
  from pathlib import Path
  from typing import Any, Dict, List, Optional
  import googleapiclient.discovery
  from google.auth.exceptions import DefaultCredentialsError
  from google.cloud import storage
  from googleapiclient.errors import HttpError
  from tabulate import tabulate
  from termcolor import colored
  from determined import util
  from determined.cli import render
  from determined.cli.errors import CliError
  from determined.common import util
  from determined.deploy import healthcheck
  from .preflight import check_quota
label_desc: Use image node_id 6 for calling a global function with example usage: terraform_write_variables(configs, variables_to_exclude) and returns: vars_file_path