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

vault.transform.getEncode

Explore with Pulumi AI

HashiCorp Vault v6.6.0 published on Thursday, Mar 13, 2025 by Pulumi

This data source supports the “/transform/encode/{role_name}” Vault endpoint.

It encodes the provided value using a named role.

Example Usage

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

const transform = new vault.Mount("transform", {
    path: "transform",
    type: "transform",
});
const ccn_fpe = new vault.transform.Transformation("ccn-fpe", {
    path: transform.path,
    name: "ccn-fpe",
    type: "fpe",
    template: "builtin/creditcardnumber",
    tweakSource: "internal",
    allowedRoles: ["payments"],
});
const payments = new vault.transform.Role("payments", {
    path: ccn_fpe.path,
    name: "payments",
    transformations: ["ccn-fpe"],
});
const test = vault.transform.getEncodeOutput({
    path: payments.path,
    roleName: "payments",
    batchInputs: [{
        value: "1111-2222-3333-4444",
    }],
});
Copy
import pulumi
import pulumi_vault as vault

transform = vault.Mount("transform",
    path="transform",
    type="transform")
ccn_fpe = vault.transform.Transformation("ccn-fpe",
    path=transform.path,
    name="ccn-fpe",
    type="fpe",
    template="builtin/creditcardnumber",
    tweak_source="internal",
    allowed_roles=["payments"])
payments = vault.transform.Role("payments",
    path=ccn_fpe.path,
    name="payments",
    transformations=["ccn-fpe"])
test = vault.transform.get_encode_output(path=payments.path,
    role_name="payments",
    batch_inputs=[{
        "value": "1111-2222-3333-4444",
    }])
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
		}
		ccn_fpe, err := transform.NewTransformation(ctx, "ccn-fpe", &transform.TransformationArgs{
			Path:        transform.Path,
			Name:        pulumi.String("ccn-fpe"),
			Type:        pulumi.String("fpe"),
			Template:    pulumi.String("builtin/creditcardnumber"),
			TweakSource: pulumi.String("internal"),
			AllowedRoles: pulumi.StringArray{
				pulumi.String("payments"),
			},
		})
		if err != nil {
			return err
		}
		payments, err := transform.NewRole(ctx, "payments", &transform.RoleArgs{
			Path: ccn_fpe.Path,
			Name: pulumi.String("payments"),
			Transformations: pulumi.StringArray{
				pulumi.String("ccn-fpe"),
			},
		})
		if err != nil {
			return err
		}
		_ = transform.GetEncodeOutput(ctx, transform.GetEncodeOutputArgs{
			Path:     payments.Path,
			RoleName: pulumi.String("payments"),
			BatchInputs: pulumi.StringMapArray{
				pulumi.StringMap{
					"value": pulumi.String("1111-2222-3333-4444"),
				},
			},
		}, nil)
		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 ccn_fpe = new Vault.Transform.Transformation("ccn-fpe", new()
    {
        Path = transform.Path,
        Name = "ccn-fpe",
        Type = "fpe",
        Template = "builtin/creditcardnumber",
        TweakSource = "internal",
        AllowedRoles = new[]
        {
            "payments",
        },
    });

    var payments = new Vault.Transform.Role("payments", new()
    {
        Path = ccn_fpe.Path,
        Name = "payments",
        Transformations = new[]
        {
            "ccn-fpe",
        },
    });

    var test = Vault.Transform.GetEncode.Invoke(new()
    {
        Path = payments.Path,
        RoleName = "payments",
        BatchInputs = new[]
        {
            
            {
                { "value", "1111-2222-3333-4444" },
            },
        },
    });

});
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.Transformation;
import com.pulumi.vault.transform.TransformationArgs;
import com.pulumi.vault.transform.Role;
import com.pulumi.vault.transform.RoleArgs;
import com.pulumi.vault.transform.TransformFunctions;
import com.pulumi.vault.transform.inputs.GetEncodeArgs;
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 ccn_fpe = new Transformation("ccn-fpe", TransformationArgs.builder()
            .path(transform.path())
            .name("ccn-fpe")
            .type("fpe")
            .template("builtin/creditcardnumber")
            .tweakSource("internal")
            .allowedRoles("payments")
            .build());

        var payments = new Role("payments", RoleArgs.builder()
            .path(ccn_fpe.path())
            .name("payments")
            .transformations("ccn-fpe")
            .build());

        final var test = TransformFunctions.getEncode(GetEncodeArgs.builder()
            .path(payments.path())
            .roleName("payments")
            .batchInputs(Map.of("value", "1111-2222-3333-4444"))
            .build());

    }
}
Copy
resources:
  transform:
    type: vault:Mount
    properties:
      path: transform
      type: transform
  ccn-fpe:
    type: vault:transform:Transformation
    properties:
      path: ${transform.path}
      name: ccn-fpe
      type: fpe
      template: builtin/creditcardnumber
      tweakSource: internal
      allowedRoles:
        - payments
  payments:
    type: vault:transform:Role
    properties:
      path: ${["ccn-fpe"].path}
      name: payments
      transformations:
        - ccn-fpe
variables:
  test:
    fn::invoke:
      function: vault:transform:getEncode
      arguments:
        path: ${payments.path}
        roleName: payments
        batchInputs:
          - value: 1111-2222-3333-4444
Copy

Using getEncode

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getEncode(args: GetEncodeArgs, opts?: InvokeOptions): Promise<GetEncodeResult>
function getEncodeOutput(args: GetEncodeOutputArgs, opts?: InvokeOptions): Output<GetEncodeResult>
Copy
def get_encode(batch_inputs: Optional[Sequence[Mapping[str, str]]] = None,
               batch_results: Optional[Sequence[Mapping[str, str]]] = None,
               encoded_value: Optional[str] = None,
               namespace: Optional[str] = None,
               path: Optional[str] = None,
               role_name: Optional[str] = None,
               transformation: Optional[str] = None,
               tweak: Optional[str] = None,
               value: Optional[str] = None,
               opts: Optional[InvokeOptions] = None) -> GetEncodeResult
def get_encode_output(batch_inputs: Optional[pulumi.Input[Sequence[pulumi.Input[Mapping[str, pulumi.Input[str]]]]]] = None,
               batch_results: Optional[pulumi.Input[Sequence[pulumi.Input[Mapping[str, pulumi.Input[str]]]]]] = None,
               encoded_value: Optional[pulumi.Input[str]] = None,
               namespace: Optional[pulumi.Input[str]] = None,
               path: Optional[pulumi.Input[str]] = None,
               role_name: Optional[pulumi.Input[str]] = None,
               transformation: Optional[pulumi.Input[str]] = None,
               tweak: Optional[pulumi.Input[str]] = None,
               value: Optional[pulumi.Input[str]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetEncodeResult]
Copy
func GetEncode(ctx *Context, args *GetEncodeArgs, opts ...InvokeOption) (*GetEncodeResult, error)
func GetEncodeOutput(ctx *Context, args *GetEncodeOutputArgs, opts ...InvokeOption) GetEncodeResultOutput
Copy

> Note: This function is named GetEncode in the Go SDK.

public static class GetEncode 
{
    public static Task<GetEncodeResult> InvokeAsync(GetEncodeArgs args, InvokeOptions? opts = null)
    public static Output<GetEncodeResult> Invoke(GetEncodeInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetEncodeResult> getEncode(GetEncodeArgs args, InvokeOptions options)
public static Output<GetEncodeResult> getEncode(GetEncodeArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: vault:transform/getEncode:getEncode
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Path
This property is required.
Changes to this property will trigger replacement.
string
Path to where the back-end is mounted within Vault.
RoleName
This property is required.
Changes to this property will trigger replacement.
string
The name of the role.
BatchInputs List<ImmutableDictionary<string, string>>
Specifies a list of items to be encoded in a single batch. If this parameter is set, the parameters 'value', 'transformation' and 'tweak' will be ignored. Each batch item within the list can specify these parameters instead.
BatchResults List<ImmutableDictionary<string, string>>
The result of encoding a batch.
EncodedValue string
The result of encoding a value.
Namespace Changes to this property will trigger replacement. string
The namespace of the target resource. 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.
Transformation string
The transformation to perform. If no value is provided and the role contains a single transformation, this value will be inferred from the role.
Tweak string
The tweak value to use. Only applicable for FPE transformations
Value string
The value in which to encode.
Path
This property is required.
Changes to this property will trigger replacement.
string
Path to where the back-end is mounted within Vault.
RoleName
This property is required.
Changes to this property will trigger replacement.
string
The name of the role.
BatchInputs []map[string]string
Specifies a list of items to be encoded in a single batch. If this parameter is set, the parameters 'value', 'transformation' and 'tweak' will be ignored. Each batch item within the list can specify these parameters instead.
BatchResults []map[string]string
The result of encoding a batch.
EncodedValue string
The result of encoding a value.
Namespace Changes to this property will trigger replacement. string
The namespace of the target resource. 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.
Transformation string
The transformation to perform. If no value is provided and the role contains a single transformation, this value will be inferred from the role.
Tweak string
The tweak value to use. Only applicable for FPE transformations
Value string
The value in which to encode.
path
This property is required.
Changes to this property will trigger replacement.
String
Path to where the back-end is mounted within Vault.
roleName
This property is required.
Changes to this property will trigger replacement.
String
The name of the role.
batchInputs List<Map<String,String>>
Specifies a list of items to be encoded in a single batch. If this parameter is set, the parameters 'value', 'transformation' and 'tweak' will be ignored. Each batch item within the list can specify these parameters instead.
batchResults List<Map<String,String>>
The result of encoding a batch.
encodedValue String
The result of encoding a value.
namespace Changes to this property will trigger replacement. String
The namespace of the target resource. 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.
transformation String
The transformation to perform. If no value is provided and the role contains a single transformation, this value will be inferred from the role.
tweak String
The tweak value to use. Only applicable for FPE transformations
value String
The value in which to encode.
path
This property is required.
Changes to this property will trigger replacement.
string
Path to where the back-end is mounted within Vault.
roleName
This property is required.
Changes to this property will trigger replacement.
string
The name of the role.
batchInputs {[key: string]: string}[]
Specifies a list of items to be encoded in a single batch. If this parameter is set, the parameters 'value', 'transformation' and 'tweak' will be ignored. Each batch item within the list can specify these parameters instead.
batchResults {[key: string]: string}[]
The result of encoding a batch.
encodedValue string
The result of encoding a value.
namespace Changes to this property will trigger replacement. string
The namespace of the target resource. 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.
transformation string
The transformation to perform. If no value is provided and the role contains a single transformation, this value will be inferred from the role.
tweak string
The tweak value to use. Only applicable for FPE transformations
value string
The value in which to encode.
path
This property is required.
Changes to this property will trigger replacement.
str
Path to where the back-end is mounted within Vault.
role_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the role.
batch_inputs Sequence[Mapping[str, str]]
Specifies a list of items to be encoded in a single batch. If this parameter is set, the parameters 'value', 'transformation' and 'tweak' will be ignored. Each batch item within the list can specify these parameters instead.
batch_results Sequence[Mapping[str, str]]
The result of encoding a batch.
encoded_value str
The result of encoding a value.
namespace Changes to this property will trigger replacement. str
The namespace of the target resource. 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.
transformation str
The transformation to perform. If no value is provided and the role contains a single transformation, this value will be inferred from the role.
tweak str
The tweak value to use. Only applicable for FPE transformations
value str
The value in which to encode.
path
This property is required.
Changes to this property will trigger replacement.
String
Path to where the back-end is mounted within Vault.
roleName
This property is required.
Changes to this property will trigger replacement.
String
The name of the role.
batchInputs List<Map<String>>
Specifies a list of items to be encoded in a single batch. If this parameter is set, the parameters 'value', 'transformation' and 'tweak' will be ignored. Each batch item within the list can specify these parameters instead.
batchResults List<Map<String>>
The result of encoding a batch.
encodedValue String
The result of encoding a value.
namespace Changes to this property will trigger replacement. String
The namespace of the target resource. 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.
transformation String
The transformation to perform. If no value is provided and the role contains a single transformation, this value will be inferred from the role.
tweak String
The tweak value to use. Only applicable for FPE transformations
value String
The value in which to encode.

getEncode Result

The following output properties are available:

BatchResults List<ImmutableDictionary<string, string>>
EncodedValue string
Id string
The provider-assigned unique ID for this managed resource.
Path string
RoleName string
BatchInputs List<ImmutableDictionary<string, string>>
Namespace string
Transformation string
Tweak string
Value string
BatchResults []map[string]string
EncodedValue string
Id string
The provider-assigned unique ID for this managed resource.
Path string
RoleName string
BatchInputs []map[string]string
Namespace string
Transformation string
Tweak string
Value string
batchResults List<Map<String,String>>
encodedValue String
id String
The provider-assigned unique ID for this managed resource.
path String
roleName String
batchInputs List<Map<String,String>>
namespace String
transformation String
tweak String
value String
batchResults {[key: string]: string}[]
encodedValue string
id string
The provider-assigned unique ID for this managed resource.
path string
roleName string
batchInputs {[key: string]: string}[]
namespace string
transformation string
tweak string
value string
batch_results Sequence[Mapping[str, str]]
encoded_value str
id str
The provider-assigned unique ID for this managed resource.
path str
role_name str
batch_inputs Sequence[Mapping[str, str]]
namespace str
transformation str
tweak str
value str
batchResults List<Map<String>>
encodedValue String
id String
The provider-assigned unique ID for this managed resource.
path String
roleName String
batchInputs List<Map<String>>
namespace String
transformation String
tweak String
value String

Package Details

Repository
Vault pulumi/pulumi-vault
License
Apache-2.0
Notes
This Pulumi package is based on the vault Terraform Provider.
HashiCorp Vault v6.6.0 published on Thursday, Mar 13, 2025 by Pulumi