DatabaseArgs

data class DatabaseArgs(val databaseDialect: Output<String>? = null, val ddls: Output<List<String>>? = null, val deletionProtection: Output<Boolean>? = null, val enableDropProtection: Output<Boolean>? = null, val encryptionConfig: Output<DatabaseEncryptionConfigArgs>? = null, val instance: Output<String>? = null, val name: Output<String>? = null, val project: Output<String>? = null, val versionRetentionPeriod: Output<String>? = null) : ConvertibleToJava<DatabaseArgs>

A Cloud Spanner Database which is hosted on a Spanner instance. To get more information about Database, see:

Warning: It is strongly recommended to set lifecycle { prevent_destroy = true } on databases in order to prevent accidental data loss.

Example Usage

Spanner Database Basic

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())
.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());
}
}

Import

Database can be imported using any of these accepted formats

$ 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}}

Constructors

Link copied to clipboard
constructor(databaseDialect: Output<String>? = null, ddls: Output<List<String>>? = null, deletionProtection: Output<Boolean>? = null, enableDropProtection: Output<Boolean>? = null, encryptionConfig: Output<DatabaseEncryptionConfigArgs>? = null, instance: Output<String>? = null, name: Output<String>? = null, project: Output<String>? = null, versionRetentionPeriod: Output<String>? = null)

Properties

Link copied to clipboard
val databaseDialect: Output<String>? = null

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.

Link copied to clipboard
val ddls: Output<List<String>>? = null

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.

Link copied to clipboard
val deletionProtection: Output<Boolean>? = null

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.

Link copied to clipboard
val enableDropProtection: Output<Boolean>? = null

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.

Link copied to clipboard

Encryption configuration for the database Structure is documented below.

Link copied to clipboard
val instance: Output<String>? = null

The instance to create the database on.

Link copied to clipboard
val name: Output<String>? = null

A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form -a-z0-9*a-z0-9.

Link copied to clipboard
val project: Output<String>? = null

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Link copied to clipboard
val versionRetentionPeriod: Output<String>? = null

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.

Functions

Link copied to clipboard
open override fun toJava(): DatabaseArgs