1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. spanner
  5. getDatabase
Google Cloud v8.26.0 published on Thursday, Apr 10, 2025 by Pulumi

gcp.spanner.getDatabase

Explore with Pulumi AI

Google Cloud v8.26.0 published on Thursday, Apr 10, 2025 by Pulumi

Get a spanner database from Google Cloud by its name and instance name.

Example Usage

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

const foo = gcp.spanner.getDatabase({
    name: "foo",
    instance: instance.name,
});
Copy
import pulumi
import pulumi_gcp as gcp

foo = gcp.spanner.get_database(name="foo",
    instance=instance["name"])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := spanner.LookupDatabase(ctx, &spanner.LookupDatabaseArgs{
			Name:     "foo",
			Instance: instance.Name,
		}, nil)
		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 foo = Gcp.Spanner.GetDatabase.Invoke(new()
    {
        Name = "foo",
        Instance = instance.Name,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.spanner.SpannerFunctions;
import com.pulumi.gcp.spanner.inputs.GetDatabaseArgs;
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 foo = SpannerFunctions.getDatabase(GetDatabaseArgs.builder()
            .name("foo")
            .instance(instance.name())
            .build());

    }
}
Copy
variables:
  foo:
    fn::invoke:
      function: gcp:spanner:getDatabase
      arguments:
        name: foo
        instance: ${instance.name}
Copy

Using getDatabase

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 getDatabase(args: GetDatabaseArgs, opts?: InvokeOptions): Promise<GetDatabaseResult>
function getDatabaseOutput(args: GetDatabaseOutputArgs, opts?: InvokeOptions): Output<GetDatabaseResult>
Copy
def get_database(instance: Optional[str] = None,
                 name: Optional[str] = None,
                 project: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetDatabaseResult
def get_database_output(instance: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 project: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetDatabaseResult]
Copy
func LookupDatabase(ctx *Context, args *LookupDatabaseArgs, opts ...InvokeOption) (*LookupDatabaseResult, error)
func LookupDatabaseOutput(ctx *Context, args *LookupDatabaseOutputArgs, opts ...InvokeOption) LookupDatabaseResultOutput
Copy

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

public static class GetDatabase 
{
    public static Task<GetDatabaseResult> InvokeAsync(GetDatabaseArgs args, InvokeOptions? opts = null)
    public static Output<GetDatabaseResult> Invoke(GetDatabaseInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetDatabaseResult> getDatabase(GetDatabaseArgs args, InvokeOptions options)
public static Output<GetDatabaseResult> getDatabase(GetDatabaseArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:spanner/getDatabase:getDatabase
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Instance This property is required. string
The name of the database's spanner instance.


Name This property is required. string
The name of the spanner database.
Project string
The project in which the resource belongs. If it is not provided, the provider project is used.
Instance This property is required. string
The name of the database's spanner instance.


Name This property is required. string
The name of the spanner database.
Project string
The project in which the resource belongs. If it is not provided, the provider project is used.
instance This property is required. String
The name of the database's spanner instance.


name This property is required. String
The name of the spanner database.
project String
The project in which the resource belongs. If it is not provided, the provider project is used.
instance This property is required. string
The name of the database's spanner instance.


name This property is required. string
The name of the spanner database.
project string
The project in which the resource belongs. If it is not provided, the provider project is used.
instance This property is required. str
The name of the database's spanner instance.


name This property is required. str
The name of the spanner database.
project str
The project in which the resource belongs. If it is not provided, the provider project is used.
instance This property is required. String
The name of the database's spanner instance.


name This property is required. String
The name of the spanner database.
project String
The project in which the resource belongs. If it is not provided, the provider project is used.

getDatabase Result

The following output properties are available:

DatabaseDialect string
Ddls List<string>
DeletionProtection bool
EnableDropProtection bool
EncryptionConfigs List<GetDatabaseEncryptionConfig>
Id string
The provider-assigned unique ID for this managed resource.
Instance string
Name string
State string
VersionRetentionPeriod string
Project string
DatabaseDialect string
Ddls []string
DeletionProtection bool
EnableDropProtection bool
EncryptionConfigs []GetDatabaseEncryptionConfig
Id string
The provider-assigned unique ID for this managed resource.
Instance string
Name string
State string
VersionRetentionPeriod string
Project string
databaseDialect String
ddls List<String>
deletionProtection Boolean
enableDropProtection Boolean
encryptionConfigs List<GetDatabaseEncryptionConfig>
id String
The provider-assigned unique ID for this managed resource.
instance String
name String
state String
versionRetentionPeriod String
project String
databaseDialect string
ddls string[]
deletionProtection boolean
enableDropProtection boolean
encryptionConfigs GetDatabaseEncryptionConfig[]
id string
The provider-assigned unique ID for this managed resource.
instance string
name string
state string
versionRetentionPeriod string
project string
database_dialect str
ddls Sequence[str]
deletion_protection bool
enable_drop_protection bool
encryption_configs Sequence[GetDatabaseEncryptionConfig]
id str
The provider-assigned unique ID for this managed resource.
instance str
name str
state str
version_retention_period str
project str
databaseDialect String
ddls List<String>
deletionProtection Boolean
enableDropProtection Boolean
encryptionConfigs List<Property Map>
id String
The provider-assigned unique ID for this managed resource.
instance String
name String
state String
versionRetentionPeriod String
project String

Supporting Types

GetDatabaseEncryptionConfig

KmsKeyName This property is required. string
Fully qualified name of the KMS key to use to encrypt this database. This key must exist in the same location as the Spanner Database.
KmsKeyNames This property is required. List<string>
Fully qualified name of the KMS keys to use to encrypt this database. The keys must exist in the same locations as the Spanner Database.
KmsKeyName This property is required. string
Fully qualified name of the KMS key to use to encrypt this database. This key must exist in the same location as the Spanner Database.
KmsKeyNames This property is required. []string
Fully qualified name of the KMS keys to use to encrypt this database. The keys must exist in the same locations as the Spanner Database.
kmsKeyName This property is required. String
Fully qualified name of the KMS key to use to encrypt this database. This key must exist in the same location as the Spanner Database.
kmsKeyNames This property is required. List<String>
Fully qualified name of the KMS keys to use to encrypt this database. The keys must exist in the same locations as the Spanner Database.
kmsKeyName This property is required. string
Fully qualified name of the KMS key to use to encrypt this database. This key must exist in the same location as the Spanner Database.
kmsKeyNames This property is required. string[]
Fully qualified name of the KMS keys to use to encrypt this database. The keys must exist in the same locations as the Spanner Database.
kms_key_name This property is required. str
Fully qualified name of the KMS key to use to encrypt this database. This key must exist in the same location as the Spanner Database.
kms_key_names This property is required. Sequence[str]
Fully qualified name of the KMS keys to use to encrypt this database. The keys must exist in the same locations as the Spanner Database.
kmsKeyName This property is required. String
Fully qualified name of the KMS key to use to encrypt this database. This key must exist in the same location as the Spanner Database.
kmsKeyNames This property is required. List<String>
Fully qualified name of the KMS keys to use to encrypt this database. The keys must exist in the same locations as the Spanner Database.

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.
Google Cloud v8.26.0 published on Thursday, Apr 10, 2025 by Pulumi