Can i create my own templated policy?

hey I’ve searched all over the documentation and also dived into the code a bit.
i didn’t find any way to create my own templated policy i only found that there is a route for getting listing and previewing the existing templated policies.

is there an undocumented route? or maybe other way to create custom templated policies?

Hi @BugaAidoc,

Currently, Consul only supports built-in templated policies. Unfortunately, our documentation of templated policies that came out with its release in Consul 1.17 doesn’t clarify that anywhere that I know of.

We will consider adding user-defined templated policies in the future. Q: Can you share more about what you wanted to use a templated policy for? This will help me understand if your use case(s) could be accommodated by directions we’ve considered for user-defined templated policies.

hi @jkirschner-hashicorp thanks for your response and sorry for the delay :slight_smile:

hmmm right now we are managing customers configuration in consul kv store.
so foreach customer we are creating policy with all the key prefixes he can read from the kv store. so lets say we have 3 customers i need 3 policies that almost looks the same
key_prefix “customer1” {
policy = “read”
key_prefix “customer2” {
policy = “read”
key_prefix “customer3” {
policy = “read”

instead i want to be able to create one policy template
key_prefix “{{customer}}” {
policy = “read”
and attach it to the role with the name of the customer as parameter.
so when i need to add another key_prefix to the template i won’t need to go over all of my policies, instead i will just change the template.

is there a better solution to my current problem? (that currently exists and supported)