getSecretV2

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as vault from "@pulumi/vault";
const kvv2 = new vault.Mount("kvv2", {
path: "kvv2",
type: "kv",
options: {
version: "2",
},
description: "KV Version 2 secret engine mount",
});
const exampleSecretV2 = new vault.kv.SecretV2("example", {
mount: kvv2.path,
name: "secret",
deleteAllVersions: true,
dataJson: JSON.stringify({
zip: "zap",
foo: "bar",
}),
});
const example = vault.kv.getSecretV2Output({
mount: kvv2.path,
name: exampleSecretV2.name,
});
import pulumi
import json
import pulumi_vault as vault
kvv2 = vault.Mount("kvv2",
path="kvv2",
type="kv",
options={
"version": "2",
},
description="KV Version 2 secret engine mount")
example_secret_v2 = vault.kv.SecretV2("example",
mount=kvv2.path,
name="secret",
delete_all_versions=True,
data_json=json.dumps({
"zip": "zap",
"foo": "bar",
}))
example = vault.kv.get_secret_v2_output(mount=kvv2.path,
name=example_secret_v2.name)
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Vault = Pulumi.Vault;
return await Deployment.RunAsync(() =>
{
var kvv2 = new Vault.Mount("kvv2", new()
{
Path = "kvv2",
Type = "kv",
Options =
{
{ "version", "2" },
},
Description = "KV Version 2 secret engine mount",
});
var exampleSecretV2 = new Vault.Kv.SecretV2("example", new()
{
Mount = kvv2.Path,
Name = "secret",
DeleteAllVersions = true,
DataJson = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["zip"] = "zap",
["foo"] = "bar",
}),
});
var example = Vault.kv.GetSecretV2.Invoke(new()
{
Mount = kvv2.Path,
Name = exampleSecretV2.Name,
});
});
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-vault/sdk/v6/go/vault"
"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/kv"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
kvv2, err := vault.NewMount(ctx, "kvv2", &vault.MountArgs{
Path: pulumi.String("kvv2"),
Type: pulumi.String("kv"),
Options: pulumi.StringMap{
"version": pulumi.String("2"),
},
Description: pulumi.String("KV Version 2 secret engine mount"),
})
if err != nil {
return err
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"zip": "zap",
"foo": "bar",
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
exampleSecretV2, err := kv.NewSecretV2(ctx, "example", &kv.SecretV2Args{
Mount: kvv2.Path,
Name: pulumi.String("secret"),
DeleteAllVersions: pulumi.Bool(true),
DataJson: pulumi.String(json0),
})
if err != nil {
return err
}
_ = kv.LookupSecretV2Output(ctx, kv.GetSecretV2OutputArgs{
Mount: kvv2.Path,
Name: exampleSecretV2.Name,
}, nil)
return nil
})
}
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.kv.SecretV2;
import com.pulumi.vault.kv.SecretV2Args;
import com.pulumi.vault.kv.KvFunctions;
import com.pulumi.vault.kv.inputs.GetSecretV2Args;
import static com.pulumi.codegen.internal.Serialization.*;
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 kvv2 = new Mount("kvv2", MountArgs.builder()
.path("kvv2")
.type("kv")
.options(Map.of("version", "2"))
.description("KV Version 2 secret engine mount")
.build());
var exampleSecretV2 = new SecretV2("exampleSecretV2", SecretV2Args.builder()
.mount(kvv2.path())
.name("secret")
.deleteAllVersions(true)
.dataJson(serializeJson(
jsonObject(
jsonProperty("zip", "zap"),
jsonProperty("foo", "bar")
)))
.build());
final var example = KvFunctions.getSecretV2(GetSecretV2Args.builder()
.mount(kvv2.path())
.name(exampleSecretV2.name())
.build());
}
}
resources:
kvv2:
type: vault:Mount
properties:
path: kvv2
type: kv
options:
version: '2'
description: KV Version 2 secret engine mount
exampleSecretV2:
type: vault:kv:SecretV2
name: example
properties:
mount: ${kvv2.path}
name: secret
deleteAllVersions: true
dataJson:
fn::toJSON:
zip: zap
foo: bar
variables:
example:
fn::invoke:
function: vault:kv:getSecretV2
arguments:
mount: ${kvv2.path}
name: ${exampleSecretV2.name}

Required Vault Capabilities

Use of this resource requires the read capability on the given path.

Return

A collection of values returned by getSecretV2.

Parameters

argument

A collection of arguments for invoking getSecretV2.


suspend fun getSecretV2(mount: String, name: String, namespace: String? = null, version: Int? = null): GetSecretV2Result

Return

A collection of values returned by getSecretV2.

Parameters

mount

Path where KV-V2 engine is mounted.

name

Full name of the secret. For a nested secret the name is the nested path excluding the mount and data prefix. For example, for a secret at kvv2/data/foo/bar/baz the name is foo/bar/baz.

namespace

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.

version

Version of the secret to retrieve.

See also


suspend fun getSecretV2(argument: suspend GetSecretV2PlainArgsBuilder.() -> Unit): GetSecretV2Result

Return

A collection of values returned by getSecretV2.

Parameters

argument

Builder for com.pulumi.vault.kv.kotlin.inputs.GetSecretV2PlainArgs.

See also