com.pulumi.gcp.spanner.kotlin.DatabaseArgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.spanner.kotlin
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.spanner.DatabaseArgs.builder
import com.pulumi.gcp.spanner.kotlin.inputs.DatabaseEncryptionConfigArgs
import com.pulumi.gcp.spanner.kotlin.inputs.DatabaseEncryptionConfigArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName
/**
* A Cloud Spanner Database which is hosted on a Spanner instance.
* To get more information about Database, see:
* * [API documentation](https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/spanner/)
* > **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
*
* ```typescript
* 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,
* });
* ```
* ```python
* 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)
* ```
* ```csharp
* 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,
* });
* });
* ```
* ```go
* 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
* })
* }
* ```
* ```java
* 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());
* }
* }
* ```
* ```yaml
* 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
* ```
*
* ## 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:
* ```sh
* $ pulumi import gcp:spanner/database:Database default projects/{{project}}/instances/{{instance}}/databases/{{name}}
* ```
* ```sh
* $ pulumi import gcp:spanner/database:Database default instances/{{instance}}/databases/{{name}}
* ```
* ```sh
* $ pulumi import gcp:spanner/database:Database default {{project}}/{{instance}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:spanner/database:Database default {{instance}}/{{name}}
* ```
* @property databaseDialect 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`.
* @property ddls 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.
* @property deletionProtection 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.
* @property enableDropProtection
* @property encryptionConfig Encryption configuration for the database
* Structure is documented below.
* @property instance The instance to create the database on.
* - - -
* @property name 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].
* @property project The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
* @property versionRetentionPeriod 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.
*/
public data class DatabaseArgs(
public val databaseDialect: Output? = null,
public val ddls: Output>? = null,
public val deletionProtection: Output? = null,
public val enableDropProtection: Output? = null,
public val encryptionConfig: Output? = null,
public val instance: Output? = null,
public val name: Output? = null,
public val project: Output? = null,
public val versionRetentionPeriod: Output? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.gcp.spanner.DatabaseArgs =
com.pulumi.gcp.spanner.DatabaseArgs.builder()
.databaseDialect(databaseDialect?.applyValue({ args0 -> args0 }))
.ddls(ddls?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
.deletionProtection(deletionProtection?.applyValue({ args0 -> args0 }))
.enableDropProtection(enableDropProtection?.applyValue({ args0 -> args0 }))
.encryptionConfig(encryptionConfig?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.instance(instance?.applyValue({ args0 -> args0 }))
.name(name?.applyValue({ args0 -> args0 }))
.project(project?.applyValue({ args0 -> args0 }))
.versionRetentionPeriod(versionRetentionPeriod?.applyValue({ args0 -> args0 })).build()
}
/**
* Builder for [DatabaseArgs].
*/
@PulumiTagMarker
public class DatabaseArgsBuilder internal constructor() {
private var databaseDialect: Output? = null
private var ddls: Output>? = null
private var deletionProtection: Output? = null
private var enableDropProtection: Output? = null
private var encryptionConfig: Output? = null
private var instance: Output? = null
private var name: Output? = null
private var project: Output? = null
private var versionRetentionPeriod: Output? = null
/**
* @param value 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`.
*/
@JvmName("flhoasyjedgujqec")
public suspend fun databaseDialect(`value`: Output) {
this.databaseDialect = value
}
/**
* @param value 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.
*/
@JvmName("tkenlfhdxdgbhfcj")
public suspend fun ddls(`value`: Output>) {
this.ddls = value
}
@JvmName("yooqkntbmjibnplt")
public suspend fun ddls(vararg values: Output) {
this.ddls = Output.all(values.asList())
}
/**
* @param values 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.
*/
@JvmName("pudsmjrutxbyahme")
public suspend fun ddls(values: List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy