1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. servicedirectory
  5. Namespace
Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi

gcp.servicedirectory.Namespace

Explore with Pulumi AI

A container for services. Namespaces allow administrators to group services together and define permissions for a collection of services.

To get more information about Namespace, see:

Example Usage

Service Directory Namespace Basic

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

const example = new gcp.servicedirectory.Namespace("example", {
    namespaceId: "example-namespace",
    location: "us-central1",
    labels: {
        key: "value",
        foo: "bar",
    },
});
Copy
import pulumi
import pulumi_gcp as gcp

example = gcp.servicedirectory.Namespace("example",
    namespace_id="example-namespace",
    location="us-central1",
    labels={
        "key": "value",
        "foo": "bar",
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/servicedirectory"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := servicedirectory.NewNamespace(ctx, "example", &servicedirectory.NamespaceArgs{
			NamespaceId: pulumi.String("example-namespace"),
			Location:    pulumi.String("us-central1"),
			Labels: pulumi.StringMap{
				"key": pulumi.String("value"),
				"foo": pulumi.String("bar"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var example = new Gcp.ServiceDirectory.Namespace("example", new()
    {
        NamespaceId = "example-namespace",
        Location = "us-central1",
        Labels = 
        {
            { "key", "value" },
            { "foo", "bar" },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.servicedirectory.Namespace;
import com.pulumi.gcp.servicedirectory.NamespaceArgs;
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 example = new Namespace("example", NamespaceArgs.builder()
            .namespaceId("example-namespace")
            .location("us-central1")
            .labels(Map.ofEntries(
                Map.entry("key", "value"),
                Map.entry("foo", "bar")
            ))
            .build());

    }
}
Copy
resources:
  example:
    type: gcp:servicedirectory:Namespace
    properties:
      namespaceId: example-namespace
      location: us-central1
      labels:
        key: value
        foo: bar
Copy

Create Namespace Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Namespace(name: string, args: NamespaceArgs, opts?: CustomResourceOptions);
@overload
def Namespace(resource_name: str,
              args: NamespaceArgs,
              opts: Optional[ResourceOptions] = None)

@overload
def Namespace(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              location: Optional[str] = None,
              namespace_id: Optional[str] = None,
              labels: Optional[Mapping[str, str]] = None,
              project: Optional[str] = None)
func NewNamespace(ctx *Context, name string, args NamespaceArgs, opts ...ResourceOption) (*Namespace, error)
public Namespace(string name, NamespaceArgs args, CustomResourceOptions? opts = null)
public Namespace(String name, NamespaceArgs args)
public Namespace(String name, NamespaceArgs args, CustomResourceOptions options)
type: gcp:servicedirectory:Namespace
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. NamespaceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. NamespaceArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. NamespaceArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. NamespaceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. NamespaceArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var gcpNamespaceResource = new Gcp.ServiceDirectory.Namespace("gcpNamespaceResource", new()
{
    Location = "string",
    NamespaceId = "string",
    Labels = 
    {
        { "string", "string" },
    },
    Project = "string",
});
Copy
example, err := servicedirectory.NewNamespace(ctx, "gcpNamespaceResource", &servicedirectory.NamespaceArgs{
	Location:    pulumi.String("string"),
	NamespaceId: pulumi.String("string"),
	Labels: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	Project: pulumi.String("string"),
})
Copy
var gcpNamespaceResource = new Namespace("gcpNamespaceResource", NamespaceArgs.builder()
    .location("string")
    .namespaceId("string")
    .labels(Map.of("string", "string"))
    .project("string")
    .build());
Copy
gcp_namespace_resource = gcp.servicedirectory.Namespace("gcpNamespaceResource",
    location="string",
    namespace_id="string",
    labels={
        "string": "string",
    },
    project="string")
Copy
const gcpNamespaceResource = new gcp.servicedirectory.Namespace("gcpNamespaceResource", {
    location: "string",
    namespaceId: "string",
    labels: {
        string: "string",
    },
    project: "string",
});
Copy
type: gcp:servicedirectory:Namespace
properties:
    labels:
        string: string
    location: string
    namespaceId: string
    project: string
Copy

Namespace Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Namespace resource accepts the following input properties:

Location
This property is required.
Changes to this property will trigger replacement.
string
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
NamespaceId
This property is required.
Changes to this property will trigger replacement.
string
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


Labels Dictionary<string, string>

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Location
This property is required.
Changes to this property will trigger replacement.
string
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
NamespaceId
This property is required.
Changes to this property will trigger replacement.
string
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


Labels map[string]string

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location
This property is required.
Changes to this property will trigger replacement.
String
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
namespaceId
This property is required.
Changes to this property will trigger replacement.
String
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


labels Map<String,String>

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location
This property is required.
Changes to this property will trigger replacement.
string
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
namespaceId
This property is required.
Changes to this property will trigger replacement.
string
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


labels {[key: string]: string}

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location
This property is required.
Changes to this property will trigger replacement.
str
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
namespace_id
This property is required.
Changes to this property will trigger replacement.
str
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


labels Mapping[str, str]

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location
This property is required.
Changes to this property will trigger replacement.
String
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
namespaceId
This property is required.
Changes to this property will trigger replacement.
String
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


labels Map<String>

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Outputs

All input properties are implicitly available as output properties. Additionally, the Namespace resource produces the following output properties:

EffectiveLabels Dictionary<string, string>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
Id string
The provider-assigned unique ID for this managed resource.
Name string
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
PulumiLabels Dictionary<string, string>
The combination of labels configured directly on the resource and default labels configured on the provider.
EffectiveLabels map[string]string
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
Id string
The provider-assigned unique ID for this managed resource.
Name string
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
PulumiLabels map[string]string
The combination of labels configured directly on the resource and default labels configured on the provider.
effectiveLabels Map<String,String>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
id String
The provider-assigned unique ID for this managed resource.
name String
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
pulumiLabels Map<String,String>
The combination of labels configured directly on the resource and default labels configured on the provider.
effectiveLabels {[key: string]: string}
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
id string
The provider-assigned unique ID for this managed resource.
name string
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
pulumiLabels {[key: string]: string}
The combination of labels configured directly on the resource and default labels configured on the provider.
effective_labels Mapping[str, str]
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
id str
The provider-assigned unique ID for this managed resource.
name str
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
pulumi_labels Mapping[str, str]
The combination of labels configured directly on the resource and default labels configured on the provider.
effectiveLabels Map<String>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
id String
The provider-assigned unique ID for this managed resource.
name String
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
pulumiLabels Map<String>
The combination of labels configured directly on the resource and default labels configured on the provider.

Look up Existing Namespace Resource

Get an existing Namespace resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: NamespaceState, opts?: CustomResourceOptions): Namespace
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        effective_labels: Optional[Mapping[str, str]] = None,
        labels: Optional[Mapping[str, str]] = None,
        location: Optional[str] = None,
        name: Optional[str] = None,
        namespace_id: Optional[str] = None,
        project: Optional[str] = None,
        pulumi_labels: Optional[Mapping[str, str]] = None) -> Namespace
func GetNamespace(ctx *Context, name string, id IDInput, state *NamespaceState, opts ...ResourceOption) (*Namespace, error)
public static Namespace Get(string name, Input<string> id, NamespaceState? state, CustomResourceOptions? opts = null)
public static Namespace get(String name, Output<String> id, NamespaceState state, CustomResourceOptions options)
resources:  _:    type: gcp:servicedirectory:Namespace    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
EffectiveLabels Dictionary<string, string>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
Labels Dictionary<string, string>

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

Location Changes to this property will trigger replacement. string
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
Name string
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
NamespaceId Changes to this property will trigger replacement. string
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
PulumiLabels Dictionary<string, string>
The combination of labels configured directly on the resource and default labels configured on the provider.
EffectiveLabels map[string]string
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
Labels map[string]string

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

Location Changes to this property will trigger replacement. string
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
Name string
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
NamespaceId Changes to this property will trigger replacement. string
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
PulumiLabels map[string]string
The combination of labels configured directly on the resource and default labels configured on the provider.
effectiveLabels Map<String,String>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
labels Map<String,String>

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

location Changes to this property will trigger replacement. String
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
name String
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
namespaceId Changes to this property will trigger replacement. String
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
pulumiLabels Map<String,String>
The combination of labels configured directly on the resource and default labels configured on the provider.
effectiveLabels {[key: string]: string}
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
labels {[key: string]: string}

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

location Changes to this property will trigger replacement. string
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
name string
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
namespaceId Changes to this property will trigger replacement. string
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
pulumiLabels {[key: string]: string}
The combination of labels configured directly on the resource and default labels configured on the provider.
effective_labels Mapping[str, str]
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
labels Mapping[str, str]

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

location Changes to this property will trigger replacement. str
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
name str
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
namespace_id Changes to this property will trigger replacement. str
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
pulumi_labels Mapping[str, str]
The combination of labels configured directly on the resource and default labels configured on the provider.
effectiveLabels Map<String>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
labels Map<String>

Resource labels associated with this Namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

location Changes to this property will trigger replacement. String
The location for the Namespace. A full list of valid locations can be found by running gcloud beta service-directory locations list.
name String
The resource name for the namespace in the format projects/*/locations/*/namespaces/*.
namespaceId Changes to this property will trigger replacement. String
The Resource ID must be 1-63 characters long, including digits, lowercase letters or the hyphen character.


project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
pulumiLabels Map<String>
The combination of labels configured directly on the resource and default labels configured on the provider.

Import

Namespace can be imported using any of these accepted formats:

  • projects/{{project}}/locations/{{location}}/namespaces/{{namespace_id}}

  • {{project}}/{{location}}/{{namespace_id}}

  • {{location}}/{{namespace_id}}

When using the pulumi import command, Namespace can be imported using one of the formats above. For example:

$ pulumi import gcp:servicedirectory/namespace:Namespace default projects/{{project}}/locations/{{location}}/namespaces/{{namespace_id}}
Copy
$ pulumi import gcp:servicedirectory/namespace:Namespace default {{project}}/{{location}}/{{namespace_id}}
Copy
$ pulumi import gcp:servicedirectory/namespace:Namespace default {{location}}/{{namespace_id}}
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.