1. Packages
  2. HashiCorp Vault
  3. API Docs
  4. kv
  5. getSecretsList
HashiCorp Vault v5.20.0 published on Tuesday, Feb 20, 2024 by Pulumi

vault.kv.getSecretsList

Explore with Pulumi AI

vault logo
HashiCorp Vault v5.20.0 published on Tuesday, Feb 20, 2024 by Pulumi

    Required Vault Capabilities

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

    Example Usage

    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 awsSecret = new Vault.Kv.Secret("awsSecret", new()
        {
            Path = kvv1.Path.Apply(path => $"{path}/aws-secret"),
            DataJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["zip"] = "zap",
            }),
        });
    
        var azureSecret = new Vault.Kv.Secret("azureSecret", new()
        {
            Path = kvv1.Path.Apply(path => $"{path}/azure-secret"),
            DataJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["foo"] = "bar",
            }),
        });
    
        var secrets = Vault.kv.GetSecretsList.Invoke(new()
        {
            Path = kvv1.Path,
        });
    
    });
    
    package main
    
    import (
    	"encoding/json"
    	"fmt"
    
    	"github.com/pulumi/pulumi-vault/sdk/v5/go/vault"
    	"github.com/pulumi/pulumi-vault/sdk/v5/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.Map{
    				"version": pulumi.Any("1"),
    			},
    			Description: pulumi.String("KV Version 1 secret engine mount"),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"zip": "zap",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = kv.NewSecret(ctx, "awsSecret", &kv.SecretArgs{
    			Path: kvv1.Path.ApplyT(func(path string) (string, error) {
    				return fmt.Sprintf("%v/aws-secret", path), nil
    			}).(pulumi.StringOutput),
    			DataJson: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON1, err := json.Marshal(map[string]interface{}{
    			"foo": "bar",
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		_, err = kv.NewSecret(ctx, "azureSecret", &kv.SecretArgs{
    			Path: kvv1.Path.ApplyT(func(path string) (string, error) {
    				return fmt.Sprintf("%v/azure-secret", path), nil
    			}).(pulumi.StringOutput),
    			DataJson: pulumi.String(json1),
    		})
    		if err != nil {
    			return err
    		}
    		_ = kv.GetSecretsListOutput(ctx, kv.GetSecretsListOutputArgs{
    			Path: kvv1.Path,
    		}, 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.Secret;
    import com.pulumi.vault.kv.SecretArgs;
    import com.pulumi.vault.kv.KvFunctions;
    import com.pulumi.vault.kv.inputs.GetSecretsListArgs;
    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 awsSecret = new Secret("awsSecret", SecretArgs.builder()        
                .path(kvv1.path().applyValue(path -> String.format("%s/aws-secret", path)))
                .dataJson(serializeJson(
                    jsonObject(
                        jsonProperty("zip", "zap")
                    )))
                .build());
    
            var azureSecret = new Secret("azureSecret", SecretArgs.builder()        
                .path(kvv1.path().applyValue(path -> String.format("%s/azure-secret", path)))
                .dataJson(serializeJson(
                    jsonObject(
                        jsonProperty("foo", "bar")
                    )))
                .build());
    
            final var secrets = KvFunctions.getSecretsList(GetSecretsListArgs.builder()
                .path(kvv1.path())
                .build());
    
        }
    }
    
    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")
    aws_secret = vault.kv.Secret("awsSecret",
        path=kvv1.path.apply(lambda path: f"{path}/aws-secret"),
        data_json=json.dumps({
            "zip": "zap",
        }))
    azure_secret = vault.kv.Secret("azureSecret",
        path=kvv1.path.apply(lambda path: f"{path}/azure-secret"),
        data_json=json.dumps({
            "foo": "bar",
        }))
    secrets = vault.kv.get_secrets_list_output(path=kvv1.path)
    
    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 awsSecret = new vault.kv.Secret("awsSecret", {
        path: pulumi.interpolate`${kvv1.path}/aws-secret`,
        dataJson: JSON.stringify({
            zip: "zap",
        }),
    });
    const azureSecret = new vault.kv.Secret("azureSecret", {
        path: pulumi.interpolate`${kvv1.path}/azure-secret`,
        dataJson: JSON.stringify({
            foo: "bar",
        }),
    });
    const secrets = vault.kv.getSecretsListOutput({
        path: kvv1.path,
    });
    
    resources:
      kvv1:
        type: vault:Mount
        properties:
          path: kvv1
          type: kv
          options:
            version: '1'
          description: KV Version 1 secret engine mount
      awsSecret:
        type: vault:kv:Secret
        properties:
          path: ${kvv1.path}/aws-secret
          dataJson:
            fn::toJSON:
              zip: zap
      azureSecret:
        type: vault:kv:Secret
        properties:
          path: ${kvv1.path}/azure-secret
          dataJson:
            fn::toJSON:
              foo: bar
    variables:
      secrets:
        fn::invoke:
          Function: vault:kv:getSecretsList
          Arguments:
            path: ${kvv1.path}
    

    Using getSecretsList

    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 getSecretsList(args: GetSecretsListArgs, opts?: InvokeOptions): Promise<GetSecretsListResult>
    function getSecretsListOutput(args: GetSecretsListOutputArgs, opts?: InvokeOptions): Output<GetSecretsListResult>
    def get_secrets_list(namespace: Optional[str] = None,
                         path: Optional[str] = None,
                         opts: Optional[InvokeOptions] = None) -> GetSecretsListResult
    def get_secrets_list_output(namespace: Optional[pulumi.Input[str]] = None,
                         path: Optional[pulumi.Input[str]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetSecretsListResult]
    func GetSecretsList(ctx *Context, args *GetSecretsListArgs, opts ...InvokeOption) (*GetSecretsListResult, error)
    func GetSecretsListOutput(ctx *Context, args *GetSecretsListOutputArgs, opts ...InvokeOption) GetSecretsListResultOutput

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

    public static class GetSecretsList 
    {
        public static Task<GetSecretsListResult> InvokeAsync(GetSecretsListArgs args, InvokeOptions? opts = null)
        public static Output<GetSecretsListResult> Invoke(GetSecretsListInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSecretsListResult> getSecretsList(GetSecretsListArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: vault:kv/getSecretsList:getSecretsList
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Path string
    Full KV-V1 path where secrets will be listed.
    Namespace 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.
    Path string
    Full KV-V1 path where secrets will be listed.
    Namespace 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.
    path String
    Full KV-V1 path where secrets will be listed.
    namespace 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.
    path string
    Full KV-V1 path where secrets will be listed.
    namespace 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.
    path str
    Full KV-V1 path where secrets will be listed.
    namespace 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.
    path String
    Full KV-V1 path where secrets will be listed.
    namespace 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.

    getSecretsList Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Names List<string>
    List of all secret names listed under the given path.
    Path string
    Namespace string
    Id string
    The provider-assigned unique ID for this managed resource.
    Names []string
    List of all secret names listed under the given path.
    Path string
    Namespace string
    id String
    The provider-assigned unique ID for this managed resource.
    names List<String>
    List of all secret names listed under the given path.
    path String
    namespace String
    id string
    The provider-assigned unique ID for this managed resource.
    names string[]
    List of all secret names listed under the given path.
    path string
    namespace string
    id str
    The provider-assigned unique ID for this managed resource.
    names Sequence[str]
    List of all secret names listed under the given path.
    path str
    namespace str
    id String
    The provider-assigned unique ID for this managed resource.
    names List<String>
    List of all secret names listed under the given path.
    path String
    namespace String

    Package Details

    Repository
    Vault pulumi/pulumi-vault
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the vault Terraform Provider.
    vault logo
    HashiCorp Vault v5.20.0 published on Tuesday, Feb 20, 2024 by Pulumi