{
  "id": "terraform-11",
  "title": "External Data Resolver",
  "description": "Declare External Data Resolvers that fetch values from your own API at query time, one with GET and one with POST, using the indykite_external_data_resolver resource.",
  "category": "External Data Resolver",
  "tags": [
    "External Data Resolver",
    "External Data",
    "ContX IQ",
    "external_value"
  ],
  "lastUpdated": "2026-10-12",
  "terraformProviderDocs": [
    "https://registry.terraform.io/providers/indykite/indykite/latest/docs/resources/external_data_resolver"
  ],
  "relatedGuides": [
    "/guides/guide-external-data-resolver",
    "/guides/guide-contx-iq",
    "/guides/guide-terraform"
  ],
  "commonErrors": [
    {
      "code": "INVALID_ARGUMENT",
      "message": "URL: destination is not permitted",
      "solution": "The host of url is a literal loopback, link-local or private address. Point the resolver at a publicly reachable endpoint."
    },
    {
      "code": "ALREADY_EXISTS",
      "message": "Conflict",
      "solution": "name is unique within the project and immutable. Choose another name, or import the existing resolver into Terraform state."
    }
  ],
  "summary": "An External Data Resolver lets a ContX IQ query read a value that lives outside the graph: a node property whose external_value names the resolver is filled at query time by calling your API.\nThis Terraform configuration creates two resolvers:\n1. A GET resolver whose URL carries a placeholder ($customer_id) filled from the query's input parameters, with an Authorization header.\n2. A POST resolver whose request_payload is a JSON body template, with the Content-Type header set.\nBoth select the value to return from the JSON answer with response_selector. The bearer token comes from a sensitive variable.",
  "usecase": "Scenario: a customer's service tier is maintained in the company's own CRM API and must not be copied into the graph.\n- A Customer node is captured with a tier property whose external_value is the resolver's name.\n- When a Knowledge Query reads that property, the platform calls the resolver with the input parameters, applies response_selector and returns the live value in the query result.\n- Changing the API's URL, headers or selector is an apply; the graph data stays untouched.",
  "requirements": "- ServiceAccount credentials created in the IndyKite Hub for your organization.\n- IndyKite Terraform provider 0.49.0 or later, the release the example pins in required_providers; the Terraform guide lists the version each feature first appeared in.\n- A project GID for project_id.\n- An HTTPS endpoint of your own that answers JSON, reachable from the public internet; a URL whose host is a literal private or loopback address is refused when the configuration is saved.",
  "steps": "1. Put your project GID in project_id, your API's URL in url and the JSON path of the value in response_selector.\n2. Provide the bearer token through the customer_api_token variable and apply.\n3. Capture a node with a property whose external_value is the resolver's name, as the External Data Resolver guide shows.\n4. Execute a Knowledge Query that reads that property; the resolver is called and its value returned.",
  "code": [
    {
      "description": "Two External Data Resolvers, GET and POST, with a placeholder in the URL and in the payload.",
      "filename": "main.tf",
      "code": "\nterraform {\n  required_providers {\n    indykite = {\n      source  = \"indykite/indykite\"\n      version = \">= 0.49.0\" # or a later release\n    }\n  }\n}\n\n# indykite provider integrates IndyKite platform with Terraform scripting.\n# Provider for now does not support any parameters and all is set within service account credential file.\nprovider \"indykite\" {}\n\n# An External Data Resolver fetches a value from your own API when a ContX IQ\n# query reads a property whose external_value names the resolver. The URL and\n# the payload may carry placeholders ($name) filled from the query's input\n# parameters; response_selector picks the value out of the JSON answer.\nresource \"indykite_external_data_resolver\" \"customer_api_get\" {\n  name         = \"terraform-resolver-get\"\n  display_name = \"Customer API (GET)\"\n  description  = \"Reads a customer record from the company API\"\n  project_id   = \"gid:AAAAAmluZHlraURlgAABDwAAAAA\" # your project GID\n\n  url    = \"https://api.example.com/customers/$customer_id\"\n  method = \"GET\"\n  headers {\n    name   = \"Authorization\"\n    values = [\"Bearer ${var.customer_api_token}\"]\n  }\n  request_type      = \"json\"\n  response_type     = \"json\"\n  response_selector = \".customer.tier\"\n}\n\n# A POST resolver sends a JSON body; request_payload is the body template.\nresource \"indykite_external_data_resolver\" \"customer_api_post\" {\n  name         = \"terraform-resolver-post\"\n  display_name = \"Customer API (POST)\"\n  description  = \"Looks a customer up by email\"\n  project_id   = \"gid:AAAAAmluZHlraURlgAABDwAAAAA\" # your project GID\n\n  url    = \"https://api.example.com/customers/search\"\n  method = \"POST\"\n  headers {\n    name   = \"Authorization\"\n    values = [\"Bearer ${var.customer_api_token}\"]\n  }\n  headers {\n    name   = \"Content-Type\"\n    values = [\"application/json\"]\n  }\n  request_type      = \"json\"\n  request_payload   = \"{\\\"email\\\": \\\"$email\\\"}\"\n  response_type     = \"json\"\n  response_selector = \".results[0].tier\"\n}\n\n# The bearer token the resolvers send to your API, kept out of the module.\nvariable \"customer_api_token\" {\n  type      = string\n  sensitive = true\n}\n"
    }
  ],
  "links": {
    "html": "/terraform/terraform-11",
    "markdown": "/terraform/terraform-11.md",
    "terraformRegistry": "https://registry.terraform.io/providers/indykite/indykite/latest/docs"
  }
}