Database Args
A Cloud Spanner Database which is hosted on a Spanner instance. To get more information about Database, see:
How-to Guides
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
Properties
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
.
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.
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 configuration for the database Structure is documented below.
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.