1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. spanner
  5. Database
Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi

gcp.spanner.Database

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi

    A Cloud Spanner Database which is hosted on a Spanner instance.

    To get more information about Database, see:

    Warning: On newer versions of the provider, you must explicitly set deletion_protection=false (and run pulumi up to write the field to state) in order to destroy an instance. It is recommended to not set this field (or set it to true) until you’re ready to destroy. On older versions, it is strongly recommended to set lifecycle { prevent_destroy = true } on databases in order to prevent accidental data loss.

    Example Usage

    Spanner Database Basic

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const main = new gcp.spanner.Instance("main", {
        config: "regional-europe-west1",
        displayName: "main-instance",
        numNodes: 1,
    });
    const database = new gcp.spanner.Database("database", {
        instance: main.name,
        name: "my-database",
        versionRetentionPeriod: "3d",
        ddls: [
            "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
            "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
        ],
        deletionProtection: false,
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    main = gcp.spanner.Instance("main",
        config="regional-europe-west1",
        display_name="main-instance",
        num_nodes=1)
    database = gcp.spanner.Database("database",
        instance=main.name,
        name="my-database",
        version_retention_period="3d",
        ddls=[
            "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
            "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
        ],
        deletion_protection=False)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/spanner"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		main, err := spanner.NewInstance(ctx, "main", &spanner.InstanceArgs{
    			Config:      pulumi.String("regional-europe-west1"),
    			DisplayName: pulumi.String("main-instance"),
    			NumNodes:    pulumi.Int(1),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = spanner.NewDatabase(ctx, "database", &spanner.DatabaseArgs{
    			Instance:               main.Name,
    			Name:                   pulumi.String("my-database"),
    			VersionRetentionPeriod: pulumi.String("3d"),
    			Ddls: pulumi.StringArray{
    				pulumi.String("CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)"),
    				pulumi.String("CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)"),
    			},
    			DeletionProtection: pulumi.Bool(false),
    		})
    		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 main = new Gcp.Spanner.Instance("main", new()
        {
            Config = "regional-europe-west1",
            DisplayName = "main-instance",
            NumNodes = 1,
        });
    
        var database = new Gcp.Spanner.Database("database", new()
        {
            Instance = main.Name,
            Name = "my-database",
            VersionRetentionPeriod = "3d",
            Ddls = new[]
            {
                "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
                "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
            },
            DeletionProtection = false,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.spanner.Instance;
    import com.pulumi.gcp.spanner.InstanceArgs;
    import com.pulumi.gcp.spanner.Database;
    import com.pulumi.gcp.spanner.DatabaseArgs;
    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 main = new Instance("main", InstanceArgs.builder()        
                .config("regional-europe-west1")
                .displayName("main-instance")
                .numNodes(1)
                .build());
    
            var database = new Database("database", DatabaseArgs.builder()        
                .instance(main.name())
                .name("my-database")
                .versionRetentionPeriod("3d")
                .ddls(            
                    "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
                    "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)")
                .deletionProtection(false)
                .build());
    
        }
    }
    
    resources:
      main:
        type: gcp:spanner:Instance
        properties:
          config: regional-europe-west1
          displayName: main-instance
          numNodes: 1
      database:
        type: gcp:spanner:Database
        properties:
          instance: ${main.name}
          name: my-database
          versionRetentionPeriod: 3d
          ddls:
            - CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)
            - CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)
          deletionProtection: false
    

    Create Database Resource

    new Database(name: string, args: DatabaseArgs, opts?: CustomResourceOptions);
    @overload
    def Database(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 database_dialect: Optional[str] = None,
                 ddls: Optional[Sequence[str]] = None,
                 deletion_protection: Optional[bool] = None,
                 enable_drop_protection: Optional[bool] = None,
                 encryption_config: Optional[DatabaseEncryptionConfigArgs] = None,
                 instance: Optional[str] = None,
                 name: Optional[str] = None,
                 project: Optional[str] = None,
                 version_retention_period: Optional[str] = None)
    @overload
    def Database(resource_name: str,
                 args: DatabaseArgs,
                 opts: Optional[ResourceOptions] = None)
    func NewDatabase(ctx *Context, name string, args DatabaseArgs, opts ...ResourceOption) (*Database, error)
    public Database(string name, DatabaseArgs args, CustomResourceOptions? opts = null)
    public Database(String name, DatabaseArgs args)
    public Database(String name, DatabaseArgs args, CustomResourceOptions options)
    
    type: gcp:spanner:Database
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args DatabaseArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args DatabaseArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args DatabaseArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DatabaseArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DatabaseArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Database Resource Properties

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

    Inputs

    The Database resource accepts the following input properties:

    Instance string
    The instance to create the database on.


    DatabaseDialect string
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    Ddls List<string>
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    DeletionProtection bool
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    EnableDropProtection bool
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    EncryptionConfig DatabaseEncryptionConfig
    Encryption configuration for the database Structure is documented below.
    Name string
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    VersionRetentionPeriod string
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    Instance string
    The instance to create the database on.


    DatabaseDialect string
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    Ddls []string
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    DeletionProtection bool
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    EnableDropProtection bool
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    EncryptionConfig DatabaseEncryptionConfigArgs
    Encryption configuration for the database Structure is documented below.
    Name string
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    VersionRetentionPeriod string
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    instance String
    The instance to create the database on.


    databaseDialect String
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    ddls List<String>
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    deletionProtection Boolean
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    enableDropProtection Boolean
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    encryptionConfig DatabaseEncryptionConfig
    Encryption configuration for the database Structure is documented below.
    name String
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    versionRetentionPeriod String
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    instance string
    The instance to create the database on.


    databaseDialect string
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    ddls string[]
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    deletionProtection boolean
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    enableDropProtection boolean
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    encryptionConfig DatabaseEncryptionConfig
    Encryption configuration for the database Structure is documented below.
    name string
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    versionRetentionPeriod string
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    instance str
    The instance to create the database on.


    database_dialect str
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    ddls Sequence[str]
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    deletion_protection bool
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    enable_drop_protection bool
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    encryption_config DatabaseEncryptionConfigArgs
    Encryption configuration for the database Structure is documented below.
    name str
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    project str
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    version_retention_period str
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    instance String
    The instance to create the database on.


    databaseDialect String
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    ddls List<String>
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    deletionProtection Boolean
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    enableDropProtection Boolean
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    encryptionConfig Property Map
    Encryption configuration for the database Structure is documented below.
    name String
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    versionRetentionPeriod String
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    State string
    An explanation of the status of the database.
    Id string
    The provider-assigned unique ID for this managed resource.
    State string
    An explanation of the status of the database.
    id String
    The provider-assigned unique ID for this managed resource.
    state String
    An explanation of the status of the database.
    id string
    The provider-assigned unique ID for this managed resource.
    state string
    An explanation of the status of the database.
    id str
    The provider-assigned unique ID for this managed resource.
    state str
    An explanation of the status of the database.
    id String
    The provider-assigned unique ID for this managed resource.
    state String
    An explanation of the status of the database.

    Look up Existing Database Resource

    Get an existing Database 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?: DatabaseState, opts?: CustomResourceOptions): Database
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            database_dialect: Optional[str] = None,
            ddls: Optional[Sequence[str]] = None,
            deletion_protection: Optional[bool] = None,
            enable_drop_protection: Optional[bool] = None,
            encryption_config: Optional[DatabaseEncryptionConfigArgs] = None,
            instance: Optional[str] = None,
            name: Optional[str] = None,
            project: Optional[str] = None,
            state: Optional[str] = None,
            version_retention_period: Optional[str] = None) -> Database
    func GetDatabase(ctx *Context, name string, id IDInput, state *DatabaseState, opts ...ResourceOption) (*Database, error)
    public static Database Get(string name, Input<string> id, DatabaseState? state, CustomResourceOptions? opts = null)
    public static Database get(String name, Output<String> id, DatabaseState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    DatabaseDialect string
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    Ddls List<string>
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    DeletionProtection bool
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    EnableDropProtection bool
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    EncryptionConfig DatabaseEncryptionConfig
    Encryption configuration for the database Structure is documented below.
    Instance string
    The instance to create the database on.


    Name string
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    State string
    An explanation of the status of the database.
    VersionRetentionPeriod string
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    DatabaseDialect string
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    Ddls []string
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    DeletionProtection bool
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    EnableDropProtection bool
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    EncryptionConfig DatabaseEncryptionConfigArgs
    Encryption configuration for the database Structure is documented below.
    Instance string
    The instance to create the database on.


    Name string
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    State string
    An explanation of the status of the database.
    VersionRetentionPeriod string
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    databaseDialect String
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    ddls List<String>
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    deletionProtection Boolean
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    enableDropProtection Boolean
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    encryptionConfig DatabaseEncryptionConfig
    Encryption configuration for the database Structure is documented below.
    instance String
    The instance to create the database on.


    name String
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    state String
    An explanation of the status of the database.
    versionRetentionPeriod String
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    databaseDialect string
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    ddls string[]
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    deletionProtection boolean
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    enableDropProtection boolean
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    encryptionConfig DatabaseEncryptionConfig
    Encryption configuration for the database Structure is documented below.
    instance string
    The instance to create the database on.


    name string
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    state string
    An explanation of the status of the database.
    versionRetentionPeriod string
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    database_dialect str
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    ddls Sequence[str]
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    deletion_protection bool
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    enable_drop_protection bool
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    encryption_config DatabaseEncryptionConfigArgs
    Encryption configuration for the database Structure is documented below.
    instance str
    The instance to create the database on.


    name str
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    project str
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    state str
    An explanation of the status of the database.
    version_retention_period str
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.
    databaseDialect String
    The dialect of the Cloud Spanner Database. If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values are: GOOGLE_STANDARD_SQL, POSTGRESQL.
    ddls List<String>
    An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
    deletionProtection Boolean
    Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a destroy or update that would delete the instance will fail.
    enableDropProtection Boolean
    Whether drop protection is enabled for this database. Defaults to false. Drop protection is different from the "deletion_protection" attribute in the following ways: (1) "deletion_protection" only protects the database from deletions in Terraform. whereas setting “enableDropProtection” to true protects the database from deletions in all interfaces. (2) Setting "enableDropProtection" to true also prevents the deletion of the parent instance containing the database. "deletion_protection" attribute does not provide protection against the deletion of the parent instance.
    encryptionConfig Property Map
    Encryption configuration for the database Structure is documented below.
    instance String
    The instance to create the database on.


    name String
    A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    state String
    An explanation of the status of the database.
    versionRetentionPeriod String
    The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. If this property is used, you must avoid adding new DDL statements to ddl that update the database's version_retention_period.

    Supporting Types

    DatabaseEncryptionConfig, DatabaseEncryptionConfigArgs

    KmsKeyName 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.
    KmsKeyName 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.
    kmsKeyName 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.
    kmsKeyName 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.
    kms_key_name 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.
    kmsKeyName 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.

    Import

    Database can be imported using any of these accepted formats:

    • projects/{{project}}/instances/{{instance}}/databases/{{name}}

    • instances/{{instance}}/databases/{{name}}

    • {{project}}/{{instance}}/{{name}}

    • {{instance}}/{{name}}

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

    $ pulumi import gcp:spanner/database:Database default projects/{{project}}/instances/{{instance}}/databases/{{name}}
    
    $ pulumi import gcp:spanner/database:Database default instances/{{instance}}/databases/{{name}}
    
    $ pulumi import gcp:spanner/database:Database default {{project}}/{{instance}}/{{name}}
    
    $ pulumi import gcp:spanner/database:Database default {{instance}}/{{name}}
    

    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.
    gcp logo
    Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi