get Secret
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as vault from "@pulumi/vault";
const kvv1 = new vault.Mount("kvv1", {
path: "kvv1",
type: "kv",
options: {
version: "1",
},
description: "KV Version 1 secret engine mount",
});
const secret = new vault.kv.Secret("secret", {
path: pulumi.interpolate`${kvv1.path}/secret`,
dataJson: JSON.stringify({
zip: "zap",
foo: "bar",
}),
});
const secretData = vault.kv.getSecretOutput({
path: secret.path,
});
Content copied to clipboard
import pulumi
import json
import pulumi_vault as vault
kvv1 = vault.Mount("kvv1",
path="kvv1",
type="kv",
options={
"version": "1",
},
description="KV Version 1 secret engine mount")
secret = vault.kv.Secret("secret",
path=kvv1.path.apply(lambda path: f"{path}/secret"),
data_json=json.dumps({
"zip": "zap",
"foo": "bar",
}))
secret_data = vault.kv.get_secret_output(path=secret.path)
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Vault = Pulumi.Vault;
return await Deployment.RunAsync(() =>
{
var kvv1 = new Vault.Mount("kvv1", new()
{
Path = "kvv1",
Type = "kv",
Options =
{
{ "version", "1" },
},
Description = "KV Version 1 secret engine mount",
});
var secret = new Vault.Kv.Secret("secret", new()
{
Path = kvv1.Path.Apply(path => $"{path}/secret"),
DataJson = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["zip"] = "zap",
["foo"] = "bar",
}),
});
var secretData = Vault.kv.GetSecret.Invoke(new()
{
Path = secret.Path,
});
});
Content copied to clipboard
package main
import (
"encoding/json"
"fmt"
"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 {
kvv1, err := vault.NewMount(ctx, "kvv1", &vault.MountArgs{
Path: pulumi.String("kvv1"),
Type: pulumi.String("kv"),
Options: pulumi.StringMap{
"version": pulumi.String("1"),
},
Description: pulumi.String("KV Version 1 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)
secret, err := kv.NewSecret(ctx, "secret", &kv.SecretArgs{
Path: kvv1.Path.ApplyT(func(path string) (string, error) {
return fmt.Sprintf("%v/secret", path), nil
}).(pulumi.StringOutput),
DataJson: pulumi.String(json0),
})
if err != nil {
return err
}
_ = kv.LookupSecretOutput(ctx, kv.GetSecretOutputArgs{
Path: secret.Path,
}, nil)
return nil
})
}
Content copied to clipboard
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.Secret;
import com.pulumi.vault.kv.SecretArgs;
import com.pulumi.vault.kv.KvFunctions;
import com.pulumi.vault.kv.inputs.GetSecretArgs;
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 kvv1 = new Mount("kvv1", MountArgs.builder()
.path("kvv1")
.type("kv")
.options(Map.of("version", "1"))
.description("KV Version 1 secret engine mount")
.build());
var secret = new Secret("secret", SecretArgs.builder()
.path(kvv1.path().applyValue(_path -> String.format("%s/secret", _path)))
.dataJson(serializeJson(
jsonObject(
jsonProperty("zip", "zap"),
jsonProperty("foo", "bar")
)))
.build());
final var secretData = KvFunctions.getSecret(GetSecretArgs.builder()
.path(secret.path())
.build());
}
}
Content copied to clipboard
resources:
kvv1:
type: vault:Mount
properties:
path: kvv1
type: kv
options:
version: '1'
description: KV Version 1 secret engine mount
secret:
type: vault:kv:Secret
properties:
path: ${kvv1.path}/secret
dataJson:
fn::toJSON:
zip: zap
foo: bar
variables:
secretData:
fn::invoke:
function: vault:kv:getSecret
arguments:
path: ${secret.path}
Content copied to clipboard
Required Vault Capabilities
Use of this resource requires the read
capability on the given path.
Return
A collection of values returned by getSecret.
Parameters
argument
A collection of arguments for invoking getSecret.
Return
A collection of values returned by getSecret.
Parameters
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.
path
Full path of the KV-V1 secret.
See also
Return
A collection of values returned by getSecret.
Parameters
argument
Builder for com.pulumi.vault.kv.kotlin.inputs.GetSecretPlainArgs.