1. Packages
  2. HashiCorp Vault Provider
  3. API Docs
  4. transform
  5. Template
HashiCorp Vault v6.6.0 published on Thursday, Mar 13, 2025 by Pulumi

vault.transform.Template

Explore with Pulumi AI

This resource supports the /transform/template/{name} Vault endpoint.

It creates or updates a template with the given name. If a template with the name does not exist, it will be created. If the template exists, it will be updated with the new attributes.

Requires Vault Enterprise with the Advanced Data Protection Transform Module. See Transform Secrets Engine for more information.

Example Usage

Please note that the pattern below holds a regex. The regex shown is identical to the one in our Setup docs, (\d{4})-(\d{4})-(\d{4})-(\d{4}). However, due to HCL, the backslashes must be escaped to appear correctly in Vault. For further assistance escaping your own custom regex, see String Literals.

import * as pulumi from "@pulumi/pulumi";
import * as vault from "@pulumi/vault";

const transform = new vault.Mount("transform", {
    path: "transform",
    type: "transform",
});
const numerics = new vault.transform.Alphabet("numerics", {
    path: transform.path,
    name: "numerics",
    alphabet: "0123456789",
});
const test = new vault.transform.Template("test", {
    path: numerics.path,
    name: "ccn",
    type: "regex",
    pattern: "(\\d{4})[- ](\\d{4})[- ](\\d{4})[- ](\\d{4})",
    alphabet: "numerics",
    encodeFormat: "$1-$2-$3-$4",
    decodeFormats: {
        "last-four-digits": "$4",
    },
});
Copy
import pulumi
import pulumi_vault as vault

transform = vault.Mount("transform",
    path="transform",
    type="transform")
numerics = vault.transform.Alphabet("numerics",
    path=transform.path,
    name="numerics",
    alphabet="0123456789")
test = vault.transform.Template("test",
    path=numerics.path,
    name="ccn",
    type="regex",
    pattern="(\\d{4})[- ](\\d{4})[- ](\\d{4})[- ](\\d{4})",
    alphabet="numerics",
    encode_format="$1-$2-$3-$4",
    decode_formats={
        "last-four-digits": "$4",
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault"
	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/transform"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		transform, err := vault.NewMount(ctx, "transform", &vault.MountArgs{
			Path: pulumi.String("transform"),
			Type: pulumi.String("transform"),
		})
		if err != nil {
			return err
		}
		numerics, err := transform.NewAlphabet(ctx, "numerics", &transform.AlphabetArgs{
			Path:     transform.Path,
			Name:     pulumi.String("numerics"),
			Alphabet: pulumi.String("0123456789"),
		})
		if err != nil {
			return err
		}
		_, err = transform.NewTemplate(ctx, "test", &transform.TemplateArgs{
			Path:         numerics.Path,
			Name:         pulumi.String("ccn"),
			Type:         pulumi.String("regex"),
			Pattern:      pulumi.String("(\\d{4})[- ](\\d{4})[- ](\\d{4})[- ](\\d{4})"),
			Alphabet:     pulumi.String("numerics"),
			EncodeFormat: pulumi.String("$1-$2-$3-$4"),
			DecodeFormats: pulumi.StringMap{
				"last-four-digits": pulumi.String("$4"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vault = Pulumi.Vault;

return await Deployment.RunAsync(() => 
{
    var transform = new Vault.Mount("transform", new()
    {
        Path = "transform",
        Type = "transform",
    });

    var numerics = new Vault.Transform.Alphabet("numerics", new()
    {
        Path = transform.Path,
        Name = "numerics",
        AlphabetSet = "0123456789",
    });

    var test = new Vault.Transform.Template("test", new()
    {
        Path = numerics.Path,
        Name = "ccn",
        Type = "regex",
        Pattern = "(\\d{4})[- ](\\d{4})[- ](\\d{4})[- ](\\d{4})",
        Alphabet = "numerics",
        EncodeFormat = "$1-$2-$3-$4",
        DecodeFormats = 
        {
            { "last-four-digits", "$4" },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vault.Mount;
import com.pulumi.vault.MountArgs;
import com.pulumi.vault.transform.Alphabet;
import com.pulumi.vault.transform.AlphabetArgs;
import com.pulumi.vault.transform.Template;
import com.pulumi.vault.transform.TemplateArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var transform = new Mount("transform", MountArgs.builder()
            .path("transform")
            .type("transform")
            .build());

        var numerics = new Alphabet("numerics", AlphabetArgs.builder()
            .path(transform.path())
            .name("numerics")
            .alphabet("0123456789")
            .build());

        var test = new Template("test", TemplateArgs.builder()
            .path(numerics.path())
            .name("ccn")
            .type("regex")
            .pattern("(\\d{4})[- ](\\d{4})[- ](\\d{4})[- ](\\d{4})")
            .alphabet("numerics")
            .encodeFormat("$1-$2-$3-$4")
            .decodeFormats(Map.of("last-four-digits", "$4"))
            .build());

    }
}
Copy
resources:
  transform:
    type: vault:Mount
    properties:
      path: transform
      type: transform
  numerics:
    type: vault:transform:Alphabet
    properties:
      path: ${transform.path}
      name: numerics
      alphabet: '0123456789'
  test:
    type: vault:transform:Template
    properties:
      path: ${numerics.path}
      name: ccn
      type: regex
      pattern: (\d{4})[- ](\d{4})[- ](\d{4})[- ](\d{4})
      alphabet: numerics
      encodeFormat: $1-$2-$3-$4
      decodeFormats:
        last-four-digits: $4
Copy

Create Template Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Template(name: string, args: TemplateArgs, opts?: CustomResourceOptions);
@overload
def Template(resource_name: str,
             args: TemplateArgs,
             opts: Optional[ResourceOptions] = None)

@overload
def Template(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             path: Optional[str] = None,
             alphabet: Optional[str] = None,
             decode_formats: Optional[Mapping[str, str]] = None,
             encode_format: Optional[str] = None,
             name: Optional[str] = None,
             namespace: Optional[str] = None,
             pattern: Optional[str] = None,
             type: Optional[str] = None)
func NewTemplate(ctx *Context, name string, args TemplateArgs, opts ...ResourceOption) (*Template, error)
public Template(string name, TemplateArgs args, CustomResourceOptions? opts = null)
public Template(String name, TemplateArgs args)
public Template(String name, TemplateArgs args, CustomResourceOptions options)
type: vault:transform:Template
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. TemplateArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. TemplateArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. TemplateArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. TemplateArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. TemplateArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var templateResource = new Vault.Transform.Template("templateResource", new()
{
    Path = "string",
    Alphabet = "string",
    DecodeFormats = 
    {
        { "string", "string" },
    },
    EncodeFormat = "string",
    Name = "string",
    Namespace = "string",
    Pattern = "string",
    Type = "string",
});
Copy
example, err := transform.NewTemplate(ctx, "templateResource", &transform.TemplateArgs{
	Path:     pulumi.String("string"),
	Alphabet: pulumi.String("string"),
	DecodeFormats: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	EncodeFormat: pulumi.String("string"),
	Name:         pulumi.String("string"),
	Namespace:    pulumi.String("string"),
	Pattern:      pulumi.String("string"),
	Type:         pulumi.String("string"),
})
Copy
var templateResource = new Template("templateResource", TemplateArgs.builder()
    .path("string")
    .alphabet("string")
    .decodeFormats(Map.of("string", "string"))
    .encodeFormat("string")
    .name("string")
    .namespace("string")
    .pattern("string")
    .type("string")
    .build());
Copy
template_resource = vault.transform.Template("templateResource",
    path="string",
    alphabet="string",
    decode_formats={
        "string": "string",
    },
    encode_format="string",
    name="string",
    namespace="string",
    pattern="string",
    type="string")
Copy
const templateResource = new vault.transform.Template("templateResource", {
    path: "string",
    alphabet: "string",
    decodeFormats: {
        string: "string",
    },
    encodeFormat: "string",
    name: "string",
    namespace: "string",
    pattern: "string",
    type: "string",
});
Copy
type: vault:transform:Template
properties:
    alphabet: string
    decodeFormats:
        string: string
    encodeFormat: string
    name: string
    namespace: string
    path: string
    pattern: string
    type: string
Copy

Template Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Template resource accepts the following input properties:

Path
This property is required.
Changes to this property will trigger replacement.
string
Path to where the back-end is mounted within Vault.
Alphabet string
The alphabet to use for this template. This is only used during FPE transformations.
DecodeFormats Dictionary<string, string>
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
EncodeFormat string
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
Name Changes to this property will trigger replacement. string
The name of the template.
Namespace Changes to this property will trigger replacement. string
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
Pattern string
The pattern used for matching. Currently, only regular expression pattern is supported.
Type string
The pattern type to use for match detection. Currently, only regex is supported.
Path
This property is required.
Changes to this property will trigger replacement.
string
Path to where the back-end is mounted within Vault.
Alphabet string
The alphabet to use for this template. This is only used during FPE transformations.
DecodeFormats map[string]string
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
EncodeFormat string
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
Name Changes to this property will trigger replacement. string
The name of the template.
Namespace Changes to this property will trigger replacement. string
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
Pattern string
The pattern used for matching. Currently, only regular expression pattern is supported.
Type string
The pattern type to use for match detection. Currently, only regex is supported.
path
This property is required.
Changes to this property will trigger replacement.
String
Path to where the back-end is mounted within Vault.
alphabet String
The alphabet to use for this template. This is only used during FPE transformations.
decodeFormats Map<String,String>
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
encodeFormat String
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
name Changes to this property will trigger replacement. String
The name of the template.
namespace Changes to this property will trigger replacement. String
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
pattern String
The pattern used for matching. Currently, only regular expression pattern is supported.
type String
The pattern type to use for match detection. Currently, only regex is supported.
path
This property is required.
Changes to this property will trigger replacement.
string
Path to where the back-end is mounted within Vault.
alphabet string
The alphabet to use for this template. This is only used during FPE transformations.
decodeFormats {[key: string]: string}
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
encodeFormat string
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
name Changes to this property will trigger replacement. string
The name of the template.
namespace Changes to this property will trigger replacement. string
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
pattern string
The pattern used for matching. Currently, only regular expression pattern is supported.
type string
The pattern type to use for match detection. Currently, only regex is supported.
path
This property is required.
Changes to this property will trigger replacement.
str
Path to where the back-end is mounted within Vault.
alphabet str
The alphabet to use for this template. This is only used during FPE transformations.
decode_formats Mapping[str, str]
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
encode_format str
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
name Changes to this property will trigger replacement. str
The name of the template.
namespace Changes to this property will trigger replacement. str
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
pattern str
The pattern used for matching. Currently, only regular expression pattern is supported.
type str
The pattern type to use for match detection. Currently, only regex is supported.
path
This property is required.
Changes to this property will trigger replacement.
String
Path to where the back-end is mounted within Vault.
alphabet String
The alphabet to use for this template. This is only used during FPE transformations.
decodeFormats Map<String>
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
encodeFormat String
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
name Changes to this property will trigger replacement. String
The name of the template.
namespace Changes to this property will trigger replacement. String
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
pattern String
The pattern used for matching. Currently, only regular expression pattern is supported.
type String
The pattern type to use for match detection. Currently, only regex is supported.

Outputs

All input properties are implicitly available as output properties. Additionally, the Template resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Template Resource

Get an existing Template resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: TemplateState, opts?: CustomResourceOptions): Template
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        alphabet: Optional[str] = None,
        decode_formats: Optional[Mapping[str, str]] = None,
        encode_format: Optional[str] = None,
        name: Optional[str] = None,
        namespace: Optional[str] = None,
        path: Optional[str] = None,
        pattern: Optional[str] = None,
        type: Optional[str] = None) -> Template
func GetTemplate(ctx *Context, name string, id IDInput, state *TemplateState, opts ...ResourceOption) (*Template, error)
public static Template Get(string name, Input<string> id, TemplateState? state, CustomResourceOptions? opts = null)
public static Template get(String name, Output<String> id, TemplateState state, CustomResourceOptions options)
resources:  _:    type: vault:transform:Template    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Alphabet string
The alphabet to use for this template. This is only used during FPE transformations.
DecodeFormats Dictionary<string, string>
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
EncodeFormat string
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
Name Changes to this property will trigger replacement. string
The name of the template.
Namespace Changes to this property will trigger replacement. string
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
Path Changes to this property will trigger replacement. string
Path to where the back-end is mounted within Vault.
Pattern string
The pattern used for matching. Currently, only regular expression pattern is supported.
Type string
The pattern type to use for match detection. Currently, only regex is supported.
Alphabet string
The alphabet to use for this template. This is only used during FPE transformations.
DecodeFormats map[string]string
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
EncodeFormat string
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
Name Changes to this property will trigger replacement. string
The name of the template.
Namespace Changes to this property will trigger replacement. string
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
Path Changes to this property will trigger replacement. string
Path to where the back-end is mounted within Vault.
Pattern string
The pattern used for matching. Currently, only regular expression pattern is supported.
Type string
The pattern type to use for match detection. Currently, only regex is supported.
alphabet String
The alphabet to use for this template. This is only used during FPE transformations.
decodeFormats Map<String,String>
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
encodeFormat String
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
name Changes to this property will trigger replacement. String
The name of the template.
namespace Changes to this property will trigger replacement. String
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
path Changes to this property will trigger replacement. String
Path to where the back-end is mounted within Vault.
pattern String
The pattern used for matching. Currently, only regular expression pattern is supported.
type String
The pattern type to use for match detection. Currently, only regex is supported.
alphabet string
The alphabet to use for this template. This is only used during FPE transformations.
decodeFormats {[key: string]: string}
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
encodeFormat string
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
name Changes to this property will trigger replacement. string
The name of the template.
namespace Changes to this property will trigger replacement. string
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
path Changes to this property will trigger replacement. string
Path to where the back-end is mounted within Vault.
pattern string
The pattern used for matching. Currently, only regular expression pattern is supported.
type string
The pattern type to use for match detection. Currently, only regex is supported.
alphabet str
The alphabet to use for this template. This is only used during FPE transformations.
decode_formats Mapping[str, str]
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
encode_format str
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
name Changes to this property will trigger replacement. str
The name of the template.
namespace Changes to this property will trigger replacement. str
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
path Changes to this property will trigger replacement. str
Path to where the back-end is mounted within Vault.
pattern str
The pattern used for matching. Currently, only regular expression pattern is supported.
type str
The pattern type to use for match detection. Currently, only regex is supported.
alphabet String
The alphabet to use for this template. This is only used during FPE transformations.
decodeFormats Map<String>
Optional mapping of name to regular expression template, used to customize the decoded output. (requires Vault Enterprise 1.9+)
encodeFormat String
The regular expression template used to format encoded values. (requires Vault Enterprise 1.9+)
name Changes to this property will trigger replacement. String
The name of the template.
namespace Changes to this property will trigger replacement. String
The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
path Changes to this property will trigger replacement. String
Path to where the back-end is mounted within Vault.
pattern String
The pattern used for matching. Currently, only regular expression pattern is supported.
type String
The pattern type to use for match detection. Currently, only regex is supported.

Package Details

Repository
Vault pulumi/pulumi-vault
License
Apache-2.0
Notes
This Pulumi package is based on the vault Terraform Provider.