Google Cloud v8.21.0 published on Wednesday, Mar 5, 2025 by Pulumi
gcp.spanner.getDatabase
Explore with Pulumi AI
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,
});
import pulumi
import pulumi_gcp as gcp
foo = gcp.spanner.get_database(name="foo",
    instance=instance["name"])
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
	})
}
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,
    });
});
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());
    }
}
variables:
  foo:
    fn::invoke:
      function: gcp:spanner:getDatabase
      arguments:
        name: foo
        instance: ${instance.name}
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>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]func LookupDatabase(ctx *Context, args *LookupDatabaseArgs, opts ...InvokeOption) (*LookupDatabaseResult, error)
func LookupDatabaseOutput(ctx *Context, args *LookupDatabaseOutputArgs, opts ...InvokeOption) LookupDatabaseResultOutput> 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)
}public static CompletableFuture<GetDatabaseResult> getDatabase(GetDatabaseArgs args, InvokeOptions options)
public static Output<GetDatabaseResult> getDatabase(GetDatabaseArgs args, InvokeOptions options)
fn::invoke:
  function: gcp:spanner/getDatabase:getDatabase
  arguments:
    # arguments dictionaryThe following arguments are supported:
getDatabase Result
The following output properties are available:
- DatabaseDialect string
- Ddls List<string>
- DeletionProtection bool
- EnableDrop boolProtection 
- EncryptionConfigs List<GetDatabase Encryption Config> 
- Id string
- The provider-assigned unique ID for this managed resource.
- Instance string
- Name string
- State string
- VersionRetention stringPeriod 
- Project string
- DatabaseDialect string
- Ddls []string
- DeletionProtection bool
- EnableDrop boolProtection 
- EncryptionConfigs []GetDatabase Encryption Config 
- Id string
- The provider-assigned unique ID for this managed resource.
- Instance string
- Name string
- State string
- VersionRetention stringPeriod 
- Project string
- databaseDialect String
- ddls List<String>
- deletionProtection Boolean
- enableDrop BooleanProtection 
- encryptionConfigs List<GetDatabase Encryption Config> 
- id String
- The provider-assigned unique ID for this managed resource.
- instance String
- name String
- state String
- versionRetention StringPeriod 
- project String
- databaseDialect string
- ddls string[]
- deletionProtection boolean
- enableDrop booleanProtection 
- encryptionConfigs GetDatabase Encryption Config[] 
- id string
- The provider-assigned unique ID for this managed resource.
- instance string
- name string
- state string
- versionRetention stringPeriod 
- project string
- database_dialect str
- ddls Sequence[str]
- deletion_protection bool
- enable_drop_ boolprotection 
- encryption_configs Sequence[GetDatabase Encryption Config] 
- id str
- The provider-assigned unique ID for this managed resource.
- instance str
- name str
- state str
- version_retention_ strperiod 
- project str
- databaseDialect String
- ddls List<String>
- deletionProtection Boolean
- enableDrop BooleanProtection 
- encryptionConfigs List<Property Map>
- id String
- The provider-assigned unique ID for this managed resource.
- instance String
- name String
- state String
- versionRetention StringPeriod 
- project String
Supporting Types
GetDatabaseEncryptionConfig   
- KmsKey stringName 
- 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.
- KmsKey List<string>Names 
- 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.
- KmsKey stringName 
- 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.
- KmsKey []stringNames 
- 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.
- kmsKey StringName 
- 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.
- kmsKey List<String>Names 
- 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.
- kmsKey stringName 
- 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.
- kmsKey string[]Names 
- 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_ strname 
- 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_ Sequence[str]names 
- 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.
- kmsKey StringName 
- 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.
- kmsKey List<String>Names 
- 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-betaTerraform Provider.