Kong's Vault environment variables doesn't work in Request Transformer plugin

145 views Asked by At

I'm setting up Kong's environment vault to store API key. My vault's config:

{
  "tags": [],
  "name": "env",
  "config": {
    "prefix": "SYSTEM_"
  },
  "id": "ed76d2a7-9ad1-441a-88ba-1eb121b366a2",
  "prefix": "system",
  "created_at": 1701327269,
  "updated_at": 1701331502,
  "description": null
}

Environment variables:

SYSTEM_GW_API_KEY=my_api_key

Then I set add.headers in Request Transformer plugin like this:

x-gw-api-key:{vault://system/system_gw_api_key}

I expect:

x-gw-api-key=my_api_key

in the backend server, but I received:

x-gw-api-key={vault://system/system_gw_api_key}

How to fix it? Seem like my syntax is incorrect, or maybe it's impossible to use Vault's variable in the plugin since I searched for the documents but found none.

1

There are 1 answers

0
Ponsakorn30214 On

You're trying to reach a Vault configuration which is located at system's environment variable. Normally, Kong response transformer plugin only allow for the transformation with given parameters in the response data e.g. body, header, etc..