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

vault.getNamespace

Explore with Pulumi AI

Example Usage

Current namespace

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

const current = vault.getNamespace({});
Copy
import pulumi
import pulumi_vault as vault

current = vault.get_namespace()
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vault.LookupNamespace(ctx, &vault.LookupNamespaceArgs{}, nil)
		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 current = Vault.GetNamespace.Invoke();

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vault.VaultFunctions;
import com.pulumi.vault.inputs.GetNamespaceArgs;
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) {
        final var current = VaultFunctions.getNamespace();

    }
}
Copy
variables:
  current:
    fn::invoke:
      function: vault:getNamespace
      arguments: {}
Copy

Single namespace

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

const ns1 = vault.getNamespace({
    path: "ns1",
});
Copy
import pulumi
import pulumi_vault as vault

ns1 = vault.get_namespace(path="ns1")
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vault.LookupNamespace(ctx, &vault.LookupNamespaceArgs{
			Path: pulumi.StringRef("ns1"),
		}, nil)
		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 ns1 = Vault.GetNamespace.Invoke(new()
    {
        Path = "ns1",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vault.VaultFunctions;
import com.pulumi.vault.inputs.GetNamespaceArgs;
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) {
        final var ns1 = VaultFunctions.getNamespace(GetNamespaceArgs.builder()
            .path("ns1")
            .build());

    }
}
Copy
variables:
  ns1:
    fn::invoke:
      function: vault:getNamespace
      arguments:
        path: ns1
Copy

Nested namespace

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

const child = vault.getNamespace({
    namespace: "parent",
    path: "child",
});
const fullPath = child.then(child => child.id);
// -> foo/parent/child/
const pathFq = child.then(child => child.pathFq);
Copy
import pulumi
import pulumi_vault as vault

child = vault.get_namespace(namespace="parent",
    path="child")
full_path = child.id
# -> foo/parent/child/
path_fq = child.path_fq
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		child, err := vault.LookupNamespace(ctx, &vault.LookupNamespaceArgs{
			Namespace: pulumi.StringRef("parent"),
			Path:      pulumi.StringRef("child"),
		}, nil)
		if err != nil {
			return err
		}
		_ := child.Id
		// -> foo/parent/child/
		_ := child.PathFq
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vault = Pulumi.Vault;

return await Deployment.RunAsync(() => 
{
    var child = Vault.GetNamespace.Invoke(new()
    {
        Namespace = "parent",
        Path = "child",
    });

    var fullPath = child.Apply(getNamespaceResult => getNamespaceResult.Id);

    // -> foo/parent/child/
    var pathFq = child.Apply(getNamespaceResult => getNamespaceResult.PathFq);

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vault.VaultFunctions;
import com.pulumi.vault.inputs.GetNamespaceArgs;
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) {
        final var child = VaultFunctions.getNamespace(GetNamespaceArgs.builder()
            .namespace("parent")
            .path("child")
            .build());

        final var fullPath = child.applyValue(getNamespaceResult -> getNamespaceResult.id());

        // -> foo/parent/child/
        final var pathFq = child.applyValue(getNamespaceResult -> getNamespaceResult.pathFq());

    }
}
Copy
variables:
  child:
    fn::invoke:
      function: vault:getNamespace
      arguments:
        namespace: parent
        path: child
  fullPath: ${child.id}
  # -> foo/parent/child/
  pathFq: ${child.pathFq}
Copy

Using getNamespace

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 getNamespace(args: GetNamespaceArgs, opts?: InvokeOptions): Promise<GetNamespaceResult>
function getNamespaceOutput(args: GetNamespaceOutputArgs, opts?: InvokeOptions): Output<GetNamespaceResult>
Copy
def get_namespace(namespace: Optional[str] = None,
                  path: Optional[str] = None,
                  opts: Optional[InvokeOptions] = None) -> GetNamespaceResult
def get_namespace_output(namespace: Optional[pulumi.Input[str]] = None,
                  path: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetNamespaceResult]
Copy
func LookupNamespace(ctx *Context, args *LookupNamespaceArgs, opts ...InvokeOption) (*LookupNamespaceResult, error)
func LookupNamespaceOutput(ctx *Context, args *LookupNamespaceOutputArgs, opts ...InvokeOption) LookupNamespaceResultOutput
Copy

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

public static class GetNamespace 
{
    public static Task<GetNamespaceResult> InvokeAsync(GetNamespaceArgs args, InvokeOptions? opts = null)
    public static Output<GetNamespaceResult> Invoke(GetNamespaceInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetNamespaceResult> getNamespace(GetNamespaceArgs args, InvokeOptions options)
public static Output<GetNamespaceResult> getNamespace(GetNamespaceArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: vault:index/getNamespace:getNamespace
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

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.
Path Changes to this property will trigger replacement. string
The path of the namespace. Must not have a trailing /. If not specified or empty, path attributes are set for the current namespace based on the namespace arguments of the provider and this data source. Other path related attributes will be empty in this case.
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.
Path Changes to this property will trigger replacement. string
The path of the namespace. Must not have a trailing /. If not specified or empty, path attributes are set for the current namespace based on the namespace arguments of the provider and this data source. Other path related attributes will be empty in this case.
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.
path Changes to this property will trigger replacement. String
The path of the namespace. Must not have a trailing /. If not specified or empty, path attributes are set for the current namespace based on the namespace arguments of the provider and this data source. Other path related attributes will be empty in this case.
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.
path Changes to this property will trigger replacement. string
The path of the namespace. Must not have a trailing /. If not specified or empty, path attributes are set for the current namespace based on the namespace arguments of the provider and this data source. Other path related attributes will be empty in this case.
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.
path Changes to this property will trigger replacement. str
The path of the namespace. Must not have a trailing /. If not specified or empty, path attributes are set for the current namespace based on the namespace arguments of the provider and this data source. Other path related attributes will be empty in this case.
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.
path Changes to this property will trigger replacement. String
The path of the namespace. Must not have a trailing /. If not specified or empty, path attributes are set for the current namespace based on the namespace arguments of the provider and this data source. Other path related attributes will be empty in this case.

getNamespace Result

The following output properties are available:

CustomMetadata Dictionary<string, string>
(Optional) A map of strings containing arbitrary metadata for the namespace. Only fetched if path is specified. Requires Vault 1.12+.
Id string
The provider-assigned unique ID for this managed resource.
NamespaceId string
Vault server's internal ID of the namespace. Only fetched if path is specified.
PathFq string
The fully qualified path to the namespace. Useful when provisioning resources in a child namespace. The path is relative to the provider's namespace argument.
Namespace string
Path string
CustomMetadata map[string]string
(Optional) A map of strings containing arbitrary metadata for the namespace. Only fetched if path is specified. Requires Vault 1.12+.
Id string
The provider-assigned unique ID for this managed resource.
NamespaceId string
Vault server's internal ID of the namespace. Only fetched if path is specified.
PathFq string
The fully qualified path to the namespace. Useful when provisioning resources in a child namespace. The path is relative to the provider's namespace argument.
Namespace string
Path string
customMetadata Map<String,String>
(Optional) A map of strings containing arbitrary metadata for the namespace. Only fetched if path is specified. Requires Vault 1.12+.
id String
The provider-assigned unique ID for this managed resource.
namespaceId String
Vault server's internal ID of the namespace. Only fetched if path is specified.
pathFq String
The fully qualified path to the namespace. Useful when provisioning resources in a child namespace. The path is relative to the provider's namespace argument.
namespace String
path String
customMetadata {[key: string]: string}
(Optional) A map of strings containing arbitrary metadata for the namespace. Only fetched if path is specified. Requires Vault 1.12+.
id string
The provider-assigned unique ID for this managed resource.
namespaceId string
Vault server's internal ID of the namespace. Only fetched if path is specified.
pathFq string
The fully qualified path to the namespace. Useful when provisioning resources in a child namespace. The path is relative to the provider's namespace argument.
namespace string
path string
custom_metadata Mapping[str, str]
(Optional) A map of strings containing arbitrary metadata for the namespace. Only fetched if path is specified. Requires Vault 1.12+.
id str
The provider-assigned unique ID for this managed resource.
namespace_id str
Vault server's internal ID of the namespace. Only fetched if path is specified.
path_fq str
The fully qualified path to the namespace. Useful when provisioning resources in a child namespace. The path is relative to the provider's namespace argument.
namespace str
path str
customMetadata Map<String>
(Optional) A map of strings containing arbitrary metadata for the namespace. Only fetched if path is specified. Requires Vault 1.12+.
id String
The provider-assigned unique ID for this managed resource.
namespaceId String
Vault server's internal ID of the namespace. Only fetched if path is specified.
pathFq String
The fully qualified path to the namespace. Useful when provisioning resources in a child namespace. The path is relative to the provider's namespace argument.
namespace String
path String

Package Details

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